Friday, 30 November 2012

Determine Factorial value using FOR loop


Write this program in Turbo C++ or DEV C++ and Compile/Run it.

#include<stdio.h>
#include<conio.h>
main(){
int n,i,f=1;
printf("Enter Number:");
scanf("%d",&n);
for(i=n; i>0; i--){
         f*=i;
}
printf("Factorial of %d is = %d",n,f);
getch();

}

Output:
Enter Number:5
Factorial of 5 is = 120

Thanks for watching...
Comment it.

No comments:

Post a Comment