lankygiant16
New Member
Im trying to do a so called "simple loop" using C,,,but i cant get it to work...this is what i have
#include <stdio.h>
int main (void)
{
int fac=1, i, num;
printf( "Enter a number: ");
scanf( "%i\n", &num);
for(i=1; i<=num; i++);
{
fac = fac * i;
printf("\nFactorial of Num is %i\n", fac);
}
return 0;
}
and what happens is i get the Enter number...i enter the number....then the program does nothing, so i enter the number again, and it gives an answer of the number entered + 1. So like if i entered in 10, it'd say the factorial is 11....which is wrong...and i dont know why its just adding one AND why its not even doing the loop. PLEASE HELP!!!!!!!!
#include <stdio.h>
int main (void)
{
int fac=1, i, num;
printf( "Enter a number: ");
scanf( "%i\n", &num);
for(i=1; i<=num; i++);
{
fac = fac * i;
printf("\nFactorial of Num is %i\n", fac);
}
return 0;
}
and what happens is i get the Enter number...i enter the number....then the program does nothing, so i enter the number again, and it gives an answer of the number entered + 1. So like if i entered in 10, it'd say the factorial is 11....which is wrong...and i dont know why its just adding one AND why its not even doing the loop. PLEASE HELP!!!!!!!!