Write a C program to find the factorial of given number using WHILE loop.

 

C PROGRAM 

C program to find the factorial of given  number using WHILE loop

#include <stdio.h>
#include<conio.h>
void main()
{
int a, fact=1;
clrscr();
printf("Enter the number:\n");
scanf("%d",&a);
while(a>1)
{
fact*=a;
a--;
}
printf("the factorial value is %d",fact);
getch();
}

OUTPUT :

Enter the number:
5
the factorial value is 120
[Process completed (code 10) - press Enter]

1 comment:




Copyright Ⓒ 2022 | Mechpedia | All Right Reserved.