Programming for Problem Solving

GTU Practical 17

17. Write a C program to find the factorial of a given number.
#include<stdio.h>  ( this applies in the given code )

#include
int main()
{
int no,fact=1;
printf(“\n Enter No to find its Factorial : “);
scanf(“%d”,&no);

while(no>1)
{
fact=fact*no;
no=no-1;
}

printf(“\n Factorial of entered no is : %d”,fact);
return 0;
}

OUTPUT

Enter No to find its Factorial : 7

Factorial of entered no is : 5040

GTU STUDY