Search This Blog

Sunday, 14 October 2012

Write a C++ program for finding factorial of a number

#include<iostream.h>
#include<conio.h>
void main()
{
int n,i,f=1;
cout<<"Get Number";
cin>>n;
for(i=1;i<=n;i++)
f=f*i;
cout<<"Factorial of n="<<f;
getch();
}

output:
5
Factorial of n=120
 

2 comments:

  1. this is very simple and perfect to understand.
    Thank you very much.............!!!!!!!!!!!!!!!!!!!!!

    ReplyDelete