CPP
Factorial of a number in C++
09 July
0
Write a program (WAP) in C++ to calculate Factorial of a numbers.
#include <iostream>
using namespace std;
int main()
{
int i,fact=1,num;
cout<<"Enter a Number:\n ";
cin>>num;
for(i=1;i<=num;i++)
{
fact=fact*i;
}
cout<<"Factorial of " <<num<<" is: "<<fact;
return 0;
}
using namespace std;
int main()
{
int i,fact=1,num;
cout<<"Enter a Number:\n ";
cin>>num;
for(i=1;i<=num;i++)
{
fact=fact*i;
}
cout<<"Factorial of " <<num<<" is: "<<fact;
return 0;
}
Out Put :-
Must Read :-
Previous article
Next article
Leave Comments
Post a Comment