Wednesday, 20 May 2020

factorial of a number

//factorial
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
//clrscr();
int num,fact;
fact=1;
cout<<"enter the number\n";
cin>>num;
for(int i=1;i<=num;i++)
{
fact=fact*i;
}
cout<<"fact="<<fact;
getch();
return 0;
}

No comments:

Post a Comment