- #1
needOfHelpCMath
- 72
- 0
Write code that prints: userNum ... 2 1 Blastoff! Your code should contain a for loop. Print a newline after each number and after Blastoff!. Ex: userNum = 3 outputs:
3
2
1
Blastoff!
Run
Testing with userNum = 3.
Your output: 3
2
1
Blastoff!
✖ Testing with userNum = 1.
Expected output: 1
Blastoff!
Your output: 3
2
1
Blastoff!
3
2
1
Blastoff!
Code:
#include <iostream>
using namespace std;
int main() {
int userNum = 0;
int i = 0;
userNum = 3;
i = 1;
for (userNum = 3; 1 <= userNum; --userNum) {
cout << userNum << endl;
}
cout << "Blastoff!" << endl;
return 0;
}
Run
Testing with userNum = 3.
Your output: 3
2
1
Blastoff!
✖ Testing with userNum = 1.
Expected output: 1
Blastoff!
Your output: 3
2
1
Blastoff!