Thread: Why the output of my program is "0" when I multiply large numbers like 256 and 8192 i

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    5

    Unhappy 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.
    Last edited by Nagasaki; 08-14-2011 at 01:53 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. multiply arbitrarily large real numbers
    By Martin0027 in forum C Programming
    Replies: 7
    Last Post: 05-17-2011, 01:59 PM
  2. Replies: 2
    Last Post: 01-30-2008, 06:12 PM
  3. How to use "switch" to perform large numbers cases?
    By megablue in forum C Programming
    Replies: 4
    Last Post: 07-09-2003, 10:51 AM
  4. "itoa"-"_itoa" , "inp"-"_inp", Why some functions have "
    By L.O.K. in forum Windows Programming
    Replies: 5
    Last Post: 12-08-2002, 08:25 AM
  5. "CWnd"-"HWnd","CBitmap"-"HBitmap"...., What is mean by "
    By L.O.K. in forum Windows Programming
    Replies: 2
    Last Post: 12-04-2002, 07:59 AM