- #1
carl123
- 56
- 0
Write a program that let's a user enter N and that outputs N! (meaning N*(N-1)*(N-2)*...*2*1). Hint: Initialize a variable totalValue to N, and use a loop variable i that counts from N-1 down to 1.
#include <iostream>
using namespace std;
int main() {
int totalVal = 0;
int userInt = 0;
// FIXME: Ask user to input an integer, store in userInt
totalVal = userInt;
// FIXME: Add while loop that counts down to 1, updating totalVal
cout << userInt <<"! is " << totalVal << endl;
return 0;
}
#include <iostream>
using namespace std;
int main() {
int totalVal = 0;
int userInt = 0;
// FIXME: Ask user to input an integer, store in userInt
totalVal = userInt;
// FIXME: Add while loop that counts down to 1, updating totalVal
cout << userInt <<"! is " << totalVal << endl;
return 0;
}