Program #6: To Print the Factorial of a Number using While Loop
C++ Language
#include<iostream.h>
#include<conio.h>
void main()
{
int i,n,f=1;
clrscr();
cout<<"Enter any Number - ";
cin>>n;
while(n>0)
{
f=f*n;
n--;
}
cout<<f;
getch();
}
/*OUTPUT*/
Enter any Number - 4
24