Man scanf and read the documentation carefully. You also need to consider how to provide information with your question. You don't even mention the language. This is for C. C++ has overloaded pow functions.

Code:

#include <stdio.h>
#include <math.h>
int main()
{
double base = 2.0;
double exp;
while (1)
{
printf ("Enter the exponent: ");
if (scanf ("%lf", &exp) == 1)
{
printf ("2 raised to the power of %f is %f\n", exp, pow (base, exp));
}
else
{
printf ("Invalid input. ");
break;
}
}
return 0;
}

Quote:

Originally Posted by **Output**
Enter the exponent: 4

2 raised to the power of 4.000000 is 16.000000

Enter the exponent: 16

2 raised to the power of 16.000000 is 65536.000000

Enter the exponent: