Home / Programs / Power series of 2 using c programming language
Programming Example

Power series of 2 using c programming language

👁 1,101 Views
💻 Practical Program
📘 Step by Step Learning
Power series of 2 using c programming language

Program Code

  
#include<stdio.h>
#include<math.h>
void main()
{
    int i,m;
    for(i=1; i<=20;  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
 2^11 = 2048
 2^12 = 4096
 2^13 = 8192
 2^14 = 16384
 2^15 = 32768
 2^16 = 65536
 2^17 = 131072
 2^18 = 262144
 2^19 = 524288
 2^20 = 1048576
Press any key to continue . . .

Explanation

Power series of 2 using c programming language

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.