Experiment 2-4-2 Generate a power table of 3 (15 points)

Enter a non-negative integer n, to generate a power in Table 3, the output 3 0 ~ 3 n- value. The power function can be called to calculate the power of 3.

Input format:

The input gives a non-negative integer n on one line .

Output format:

Output n + 1 lines in increasing order of power , each line format is "pow (3, i) = 3 to the power of i value". The problem is to ensure that the output data does not exceed the range of long integers.

Sample input:

3
 

Sample output:

pow(3,0) = 1
pow(3,1) = 3
pow(3,2) = 9
pow(3,3) = 27



#include<stdio.h>
#include<math.h>
int main ()
{
    int i,n;
    int I = 0;
    scanf("%d",&n);

        for(i=0;i<=n;i++)
   {
        sum=pow(3,i);
        printf("pow(3,%d) = %d\n",i,sum);
   }
    return 0;
}

Guess you like

Origin www.cnblogs.com/wven/p/12681201.html