what is wrong here?

This is a discussion on what is wrong here? within the C Programming forums, part of the General Programming Boards category; *hits her head against the monitor* I just can't see why I'm getting the result I'm getting.... #include <stdio.h> int ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    17

    what is wrong here?

    *hits her head against the monitor* I just can't see why I'm getting the result I'm getting....

    #include <stdio.h>

    int main()
    {
    int x,y;
    long int result;
    x= 1000;
    y= 7000;
    result= x*y;

    printf("The results of 1000 multiplied by 7000 is %lu.\n", result);

    return 0;
    }

    And it's coming out to be...53184? Eh?

  2. #2
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669
    I compiled your code and I get 7000000. Change x and y into long int.
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  3. #3
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    on my compiler (bloodshed dev c++ 4) and computer (athlon 1ghz) i'm getting 7000000
    maybe on your computer and compiler ints are plus/minus ~37000.

    in either case, try making x and y long ints, then recompile and tell us your results.

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    17

    yay! it works now!

    it works now. Making x and y long got it to work. Thanks you two

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 07-15-2004, 03:30 PM
  2. Debugging-Looking in the wrong places
    By JaWiB in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-03-2003, 09:50 PM
  3. Confused: What is wrong with void??
    By Machewy in forum C++ Programming
    Replies: 19
    Last Post: 04-15-2003, 12:40 PM
  4. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 11:01 AM
  5. Whats wrong?
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 07-14-2002, 01:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21