Thursday, 14 April 2016

writa a program to take input from user and printout it's factorial as an output.

#include <iostream.h>
#include <conio.h>
void main ()
{
int n;
long int fact;
cout << "Enter any number which you want to printout it's factorial ";
cin >> n;
fact = 1;
for ( ; n>=1; n--)
fact = fact * n;
cout << fact ;
getch ();
}

 for example:

if you enter 5
it's answer will be:      5*4*3*2*1 = 120


Output:
Enter any number which you want to printout it's factorial 5
120

1 comment: