Home / Programs / Power function in c programming language || pow(2,i)
Programming Example

Power function in c programming language || pow(2,i)

👁 1,035 Views
💻 Practical Program
📘 Step by Step Learning
Power function in c programming language pow(2,i)

Program Code

  
#include<stdio.h>
#include<math.h>
void main()
{
    int i,m;
    for(i=1; i<=10;  i++)
    {
    	m = pow(2,i);
        printf(" 2^%d = %d \n",i,m);
        
    }
   
} 

Output

 2^1 = 2
 2^2 = 4
 2^3 = 8
 2^4 = 16
 2^5 = 32
 2^6 = 64
 2^7 = 128
 2^8 = 256
 2^9 = 512
 2^10 = 1024
Press any key to continue . . .

Explanation

Power function in c programming language pow(2,i)

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.