problem in printing factorial.............
-
hello every one I am a beginner in c language I am trying to print factorial of number using the program given below...... #include<stdio.h> void main() { int fact=1,counter=5; clrscr(); while(counter>0) { fact = fact * counter; counter--; } printf("fact of %d is: %d",counter,fact); getch(); } I need output as <b>Fact of 5 is 120.</b>
-
hello every one I am a beginner in c language I am trying to print factorial of number using the program given below...... #include<stdio.h> void main() { int fact=1,counter=5; clrscr(); while(counter>0) { fact = fact * counter; counter--; } printf("fact of %d is: %d",counter,fact); getch(); } I need output as <b>Fact of 5 is 120.</b>
The program seems fine. What is the error you are getting?
Anurag Gandhi. http://www.gandhisoft.com Life is a computer program and every one is the programmer of his own life.
-
hello every one I am a beginner in c language I am trying to print factorial of number using the program given below...... #include<stdio.h> void main() { int fact=1,counter=5; clrscr(); while(counter>0) { fact = fact * counter; counter--; } printf("fact of %d is: %d",counter,fact); getch(); } I need output as <b>Fact of 5 is 120.</b>
-
hello every one I am a beginner in c language I am trying to print factorial of number using the program given below...... #include<stdio.h> void main() { int fact=1,counter=5; clrscr(); while(counter>0) { fact = fact * counter; counter--; } printf("fact of %d is: %d",counter,fact); getch(); } I need output as <b>Fact of 5 is 120.</b>
-
void main()
{
clrscr();
int fact=1, counter=5;
int term = 1;
while(term <= counter)
{
fact = fact * term;
term++;
}
printf("fact of %d is: %d", counter, fact);getch();
}
modified on Saturday, December 12, 2009 4:55 AM
-
hello every one I am a beginner in c language I am trying to print factorial of number using the program given below...... #include<stdio.h> void main() { int fact=1,counter=5; clrscr(); while(counter>0) { fact = fact * counter; counter--; } printf("fact of %d is: %d",counter,fact); getch(); } I need output as <b>Fact of 5 is 120.</b>
-
And just how does this loop end?
while(counter <= counter)
Perhaps you meant
while(term <= counter)
Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193