Friday 12 October 2012

C++ programme for calculating factorial

Here goes the program. Please copy it in notepad and save it as .cpp file and open c++ and run it.

#include<iostream.h>
#include<conio.h>
void factorial(int a)
{
int x=1,n,b;
b = a;
for(a;a>0;a--)
x=a*x;
cout<<x;
}
void main()
{
int a;
clrscr();
cout<<"Enter a number to get factorial";
cin>>a;
factorial(a);
getch();
}

No comments:

Post a Comment