1) Write a C++ program to calculate x raised to the y power. The program should have a while repetition control structure.solved
2) Print the integers form 1 to 20 using a while loop and the counter variable x. Assume that the variable x has been declared, but not initialized. Print only 5 integers per line. Hint: Use the calculation x%5. When the value of this is 0, print a newline character, otherwise print a tab character.
I'll help you write that if you'd like but I'm not doing your assignment for you because that won't help you at all. Make a stab at the code, post it here and we'll dutifully give you help but you get nowhere in life just asking for it to be done for you.
#include <iostream>
usingnamespace std;
int main()
{
int x, y, i, power;
i = 1;
power = 1;
cout << "Enter x: ";
cin >> x;
cout << "Enter y: ";
cin >> y;
while ( i <= y ) { // to multiply the x itself to the no. of y
power = power * x;
i++;
}
cout << "x to the power y is: " << power << endl;
return 0;
}