C++ Program for Factorial of Numbers in a Given Range

Program Code:

#include<iostream>

using namespace std;
int main()
{
int fact =1 ,n;
cout<<"Enter Range A :  ";
cin>>n;
cout<<"\n\n";
cout<<"A\t\tFactorial A\n\n";
    for(int i =1;i<n;i++)
{
for(int j=1;j<=i;j++)
{
fact = fact * j;
}
cout<<i<<"\t\t"<<fact; 
cout<<endl;
fact = 1;
}
return 0;
}

Output:

.exe file


No comments:

Post a Comment

Please disable your ad blocker to support this website.

Our website relies on revenue from ads to keep providing free content.