/* calculate factorial value using do while */
#include<stdio.h>#include<conio.h>
void main()
{
long int i,n,fact=1; /*variable declaration */
clrscr();
printf("Enter the value of n \n");
scanf("%ld", &n);
/* do loop start */
i=1;
do
{
fact*=i;
i++;
}
while(i<=n);
printf("Factorial = %ld\n",fact);
getch();
}
output
enter the value of n6
factorial = 720
Comments
Post a Comment