Tuesday, March 1, 2016

Factorial in C

1:  #include <stdio.h>  
2:    
3:  int main()  
4:  {  
5:      int n,factorial;  
6:      factorial=1;  
7:      printf("Enter your number: ");  
8:      scanf("%d",&n);  
9:      while(n>0){  
10:          factorial=factorial*n;  
11:          --n;  
12:            
13:      }  
14:      printf("Your factorial number is : %d",factorial);  
15:      return 0;  
16:      }  

No comments:

Post a Comment

Thank you for commenting. Please wait for response :)