no biggie. Just making sure.
no biggie. Just making sure.
"You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter
ItsMe and FillYourBrain: Thanks a ton for your help. I really appreciate it. I'm going to look at these examples and apply them to my exercise. Again, sorry for my stubborness. I'm still a rookie at this. I appreciate the patience.
Cheers!
Hey, wow! I'm learning factorials too! That was an awesome factorial program!
How does the *= work?
Thanks!
mw
Last edited by Lionmane; 05-24-2005 at 10:14 PM.
x *= y is short hand for x = x * y
Same rule applies to += -= /= %= ^= &= etc
fine I guess I should have given more explaination 2 my code :P
ok I assumed that the user would want to tell the program which numbers it wants it to find the factorial to :P
so if the user enters 5 for example it would resul inCode:int i , sum = 1 ; printf("Enter value"); scanf("%d" , & value ); for ( i = value ; i > 0 ; i-- ) sum = sum * i ; printf("The result is % d \n" , sum );
5 * 4 * 3 * 2 * 1 = 120 :P
sorrry if i caused loads of cunfusion !! :P:P:P:P
Also forgot to declaure value as int :P
Code:int main() { int i , value , sum = 1 ; printf("Enter value"); scanf("%d" , & value ); for ( i = value ; i > 1 ; i-- ) sum = sum * i ; printf("The result is % d \n" , sum ); return(0); }