Hi all!
I'm a newbie and wonder why:
int a, b, c;
a = 5;
b = 12000;
c = a*b;
printf("%d", c);
does not yield 60000
Please help!
Hi all!
I'm a newbie and wonder why:
int a, b, c;
a = 5;
b = 12000;
c = a*b;
printf("%d", c);
does not yield 60000
Please help!
Um, it looks okay to me.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
60000 is probably to big for an integer to hold on your system. Use a long int instead, and writeto specify a long digit.Code:printf("%ld", c);
Ah, that makes sense. I thought an integer could hold higher numbers... guess it does depend on the system and/or the compiler...
Thanks!
BTW what complier/os are you using?
Woop?
The thing is, I'm not, but I have this "study" question that asked this question and I couldn't figure out why.... it wasn't suppose to work...
Very sneaky way to get people to do your work GJ
Woop?
yeah.... now I have a different problem I have no answer to...... maybe you could answer exactly what this function does with the string...
Code:void foo(char *string, int length) { char temp; if(length < 2) return; else { temp = *string; *string = string[length - 1]; string[length -1] = temp; foo(string+1, length-2); } }
it recursively reverses the characters in the string. If this is homework, read the board policy.
No No's:
fflush (stdin); gets (); void main ();
Goodies:
Example of fgets (); The FAQ, C/C++ Reference
My Gear:
OS - Windows XP
IDE - MS Visual C++ 2008 Express Edition
ASCII stupid question, get a stupid ANSI
I've got a better idea. Make a test program, stick the function in it, and find out for yourself.Originally Posted by MrMe
Quzah.
Hope is the first step on the road to disappointment.