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 s or c?

0 Answers  


A program to write a number of letters and numbers, such as counting and display

0 Answers  


write a program that uses point of sale system. which are mainly used by retail markets, where the is a database inventory list, a slip should be printed for the customer. manage should be able to access what has been sold and what is left from stock?

1 Answers  


What does the format %10.2 mean when included in a printf statement?

0 Answers  


what is the defrenece between structure and union

5 Answers   Aloha Technology,


what is c programing

11 Answers   Wipro,


What is hash table in c?

0 Answers  


What is || operator and how does it function in a program?

0 Answers  


What is 'bus error'?

0 Answers  


Place the #include statement must be written in the program?

0 Answers  


List some applications of c programming language?

0 Answers  


Can a function argument have default value?

0 Answers   Genpact,


Categories