06 December, 2015

Factorial of a Number in C Program using For Loop

C Program to find Factorial of any given Number
#include<stdio.h>
#include<conio.h>
Void main() {
 int n,i,f=1;
 clrscr();
 printf("Enter any number: ");
 scanf("%d", &n);
 for(i=1;i<=n;i++) {
  f=f*i;
 }
 printf("Factorial of %d is %d",n,f);
 getch();
}


Output:
Enter any number: 5
Factorial of 5 is 120

No comments:

Post a Comment

If you need more information about any topic, feel free to comment here!