#include <iostream>
using namespace std;
//main method
int main()
{
int Number;//variable for input number
int Factorial=1;//variable for result
//promt user to enter Number
cout<<"Enter a Number: ";
//read number
cin>>Number;
for(int i=1;i<=Number;i++){
Factorial*=i;
}
//show result
cout<<"Factorial value: "<<Factorial<<"\n";
//delay
system("pause");
//exit program
return 0;
}
Comments
1. Write a program that compute the factorial value of n (as input) and display it. Algorithm: Enter a number: (n) F=1; For(i=0; i>=1; i--); { F=F*i; } Printf("\n the factorial value: %d",F); Example output: Enter a number: 5 as input number The factorial value: 120 → output value
Leave a comment