C++ PROGRAM TO FIND THE FACTORIAL OF A NUMBER
Sample Test Case : Enter a Number : 5
Sample Test Case : Factorial of 5 is 120
CODE
#include<stdio.h>
int main()
{
int num,fact=1;
cout<<"Enter a Number :";
cin>>num;
for(int a=1;a<=num;a++)
{
factorial=fact*a;
}
cout<<"Factorial of "<<num<<" is"<<fact;
return 0;
}

No comments:
Post a Comment