Table of Contents
show
Syntax
while(expression)
{
statement
}
Flowchart
Example
Factorial of a number
//Factorial of a number
#include<stdio.h>
int main()
{
int num, lc=1, fact=1;
printf("Enter a number\t");
scanf("%d",&num);
while(lc<=num)
{
fact = fact *lc;
lc=lc+1;
}
printf("Factorial is %d",fact);
return 0;
}
Output
Enter a number 5
Factorial is 120
Views: 0