Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Why doesn't the code "int a = 1000, b = 1000;
long int c = a * b;" work?

Answers were Sorted based on User's Feedback



Why doesn't the code "int a = 1000, b = 1000; long int c = a * b;" work?..

Answer / larry

This won't work if int is a 16-bit size because 1000000 >
32767 (2 to the 15th - 1). It will work when int is a 32-
bit number. It will work if you cast a or b to a long.

Is This Answer Correct ?    5 Yes 0 No

Why doesn't the code "int a = 1000, b = 1000; long int c = a * b;" work?..

Answer / thirupathi reddy katkoori

Integer range exceeds if multiply both the variables the resultant value does not to store it. Due to exceeding the int range only we have to declare it as long int and the value is store in c

Is This Answer Correct ?    1 Yes 0 No

Why doesn't the code "int a = 1000, b = 1000; long int c = a * b;" work?..

Answer / guest

You must manually cast one of the operands to (long).

Is This Answer Correct ?    1 Yes 1 No

Why doesn't the code "int a = 1000, b = 1000; long int c = a * b;" work?..

Answer / vikraman85

I think mostly we should avoid assigning the variables while
declaring with the variables of another datatype..

Is This Answer Correct ?    0 Yes 1 No

Why doesn't the code "int a = 1000, b = 1000; long int c = a * b;" work?..

Answer / vignesh1988i

this will work.... correctly

Is This Answer Correct ?    0 Yes 1 No

Why doesn't the code "int a = 1000, b = 1000; long int c = a * b;" work?..

Answer / shruti

i think, the result exceeds the long int value..

the result is 10 and 6 0s..

and it exceeds the value for the long in

long int is 4 bytes..
the highest value is 65524 (m not very sure.. this could be
one of the reasons)..

Is This Answer Correct ?    0 Yes 2 No

Why doesn't the code "int a = 1000, b = 1000; long int c = a * b;" work?..

Answer / komal

it wont work as we have to declare the variable 'b'
again...we can not declare it like int a=10,b=3;
it has to b like int a=10;
int b=6;

Is This Answer Correct ?    0 Yes 4 No

Post New Answer

More C Interview Questions

what is constant pointer?

3 Answers  


What is structure of c program?

0 Answers  


What does volatile do?

0 Answers  


hi how to convert program from notepad to turboc editor can u please help me

3 Answers  


what is the advantage of software development

1 Answers  


CAN ANYONE PLEASE HELP ON THIS PROGRAM FOR MY EXAM..TQ Write a C program to help a H’s Restaurant automate its breakfast billing system. Your assignment should implement the following items: a. Show the customer the different breakfast items offered by the H’s Restaurant. b. Allow the customer to select more than one item from the menu. c. Calculate and print the bill to the customer. d. Produce a report to present your complete program and show more sample output. Assume that the H’s Restaurant offers the following breakfast menu: Plain Egg $2.50 Bacon and Egg $3.45 Muffin $2.20 French Toast $2.95 Fruit Basket $3.45 Cereal $0.70 Coffee $1.50 Tea $1.80 Your program must do the following task below: a. Define the data structs, menu item types with two components: menu item of type string and menu price of type double. Use an array to declare the data structs. b. Function get data to loads the data into the array menu list. c. Function show menu to show the different breakfast items offered by the restaurant and tell the user how to select the items. d. Function print receipt to calculates and prints the customer receipt. The billing amount should include a 5% tax. e. Format your output with two decimal places. The name of each item in the output must be left-justify. You may assume that the user selects only one item of a particular type. f. The two sample output as shown: Welcome to HiFi’s Restaurant 1 Bacon and Egg $3.45 1 Muffin $2.20 1 Coffee $1.50 Tax 5% $0.35 Amount Due $7.50

1 Answers  


What are the primitive data types in c?

0 Answers  


What should malloc() do?

0 Answers  


Write down the program to sort the array.

4 Answers   Impiger,


main() { int i; printf("%d",i^i); }

1 Answers  


What is the purpose of clrscr () printf () and getch ()?

0 Answers  


the maximum width of a c variable name can be a) 6 characters b) 8 characters c) 10 characters d) 20 characters

2 Answers  


Categories