Write a C++ statement that do the following
Write a C++ statement that do the following:
- Input integer variable x with cin and >>
- Input integer variable y with cin and >>
- Initialize the variable i to 1.
- Initialize the variable power to 1.
- Multiply variable power by x assign the result to power.
- Increment variable y to 1.
- Test y to see if it is less than or equal to x.
- Out put integer variable power with cout and <<.
Solution
- cin >> x;
- cin >> y;
- i = 1;
- power = 1;
- power *= x;
- i++;
- if( i <= y )
- cout << power << endl;
If You Enjoyed This, Take 5 Seconds To Share It
0 Questions:
Post a Comment