I can't figure out how to get the proper output. The code gives me an output like: Enter a positive integer: 5
5^5=25
• asks the user to a positive integer between 1 and 10
• checks that the value entered is valid, if not ask the user repeatedly
until an integer between 1 and 10 is entered.
• calculates and prints out x
x
(DO NOT USE pow() ) as shown
below
Here is an example of the program should work:
Enter a number between 1 and 10: 6
6^1 = 6
6^2 = 36
6^3 = 216
6^4 = 3296
6^5 = 19776
6^6 = 118656
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
usingnamespace std;
int main() {
int x;
cout << "Enter a positive integer: ";
cin >> x;
while (x <= 0) {
cout << "Please enter a positive value: ";
cin >> x;
}
int result = 1;
for (int i = 1; i <= x; i++){
result = i++ * x;}
cout <<x<<"^"<<x++<<"="<<result<< endl;
return 0;