Answer to Question #47568 in C++ for krad

Question #47568
Write a program to calculate the factorial value of the input number n! use the incrementation formula (i++) for your solution instead of decrementation formula (1--).
Sample input/output dialogue:
Enter a Number: 4
Factorial value: 24
(The computation is: 1*2*3*4=24)
1
Expert's answer
2014-10-10T02:06:04-0400
#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;
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

blackpanthom
17.05.21, 10:20

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

LATEST TUTORIALS
APPROVED BY CLIENTS