Home / Programs / power function in c programming language
Programming Example

power function in c programming language

👁 899 Views
💻 Practical Program
📘 Step by Step Learning
power function in c programming language

Program Code

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

Output

 1^2 = 1
 2^2 = 4
 3^2 = 9
 4^2 = 16
 5^2 = 25
 6^2 = 36
 7^2 = 49
 8^2 = 64
 9^2 = 81
 10^2 = 100
Press any key to continue . . .

Explanation

power function in 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.