Why the output of my program is "0" when I multiply large numbers like 256 and 8192
Hi. Could someone help me. I am making a C language program that will display the product of any large number, but I a getting 0 instead! Here is a sample program that I made...
Source code:
Code:
#include<stdio.h>
#include<conio.h>
int main();
{
long long int a=256;
long long int b=8192;
long long int ans=a*b;
printf("%d",ans);
getch();
return 0;
}
Output: 0
We all know that 256 x 8192 = 2097152, but why the computer is still displays "0"? I tried changing ans to double, but still it is "0". What will I do?
PS. If you will make a program modifying it, please make it as simple as possible. Thanks.