WAP to print the factorial of a number using "While Loop"

//WAP to print the factorial of a number using "While Loop"//

#include<stdio.h>
#include<conio.h>
void main()
{
 int i, n, fact=1;
 printf("Enter the number whose factorial is to be checked\n");
 scanf("%d", n);
 i=n;
 while (i>=1)
 {
  fact=fact*i;
  i=i-1;
 }
 printf("Factorial of the number is:-  %d\n", fact);
 getch();
}


  • The Input and Output of this program is shown in the pictures below:-                                                                                                                                                                                                                                   INPUT                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                        OUTPUT                                                                                                               
                                                                                                                                                                                             
      

Comments