in it were supposed to type a number and the program should display it's square, cube, number^4, number^5,..., number^10.
How can i make this using the while loop?
#include <iostream>
usingnamespace std;
int main()
{
int num = 0;
int num2;
int i = 2;
cout << "Enter number :" << endl;
cin >> num;
while (i <= 10)
{
num2 = pow(num, i);
cout << "power of number is " << num2 << endl;
i++;
}
system("pause");
return 0;
}
#include <iostream>
usingnamespace std;
double raiseToPow(int number, int power)
{
double result;
int i;
result =1.0;
for (i=1;i<=power;i++)
{
result = result*number;
}
return(result);
}
int main()
{
int num=0;
int i=1;
double result;
std::cout<<"Enter number :"<<endl;
std::cin>>num;
while(i<=10){
result= raiseToPow(num,i);
cout<<endl<<num<<" number power "<<i<<" is "<<result<<endl;
i++;
}
return 0;
}