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!
Printable View
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.
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! :D
BTW what complier/os are you using?
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 ;)
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.
I've got a better idea. Make a test program, stick the function in it, and find out for yourself.Quote:
Originally Posted by MrMe
Quzah.