If you are in school, college, or taking a course in programming in C + +, this year, if that is typical, although not required many instructions, it works perfect.
The statement would be this:
Read a data and store it in variable n , read other data and store it in variable x .
Calculate the value of x raised to the power n .
In other words, will the well-known program for the powers.
then develop it used a CYCLE FOR , but remember that these exercises cycles can be rewritten to conform to instructions and while and do while .
# include \u0026lt;iostream.h>will notice that the key task is to assign a value for the variable ANS before the cycle, and as this is a multiplication exercise, we should build on the property modulated product, so the initial value is 1.
int base,potencia,ans,i;
int main ( void )
{
cout << "Por favor ingrese la base" <<endl;
cin >> base;
cout << "Por favor ingrese la potencia" <<endl;
cin >> potencia;
ans=1;
for (i=1 ; i<=potencia; i++)
{
ans=ans*base;
}
cout << "El resultado es " <<ans<<endl;
system("pause");
return 0;}
0 comments:
Post a Comment