C Program to find the power of a number without using library functions
OR
C Program to evaluate “a” to the power “b” without using library functions.
In this program, we are going to calculate the power of a number. First we initialize the base and power variable. Then, we take their values by user. we are using for loop here to calculate the answer
#include<stdio.h>
#include<conio.h>
void main()
{
int base,power,i,temp=1;
clrscr();
printf(“Enter Base:”);
scanf(“%d”,&base);
printf(“Enter Power:”);
scanf(“%d”,&power);
for(i=1;i<=power;i++)
temp=temp*base;
printf(“Result: %d”,temp);
getch;
}
Output:-
Recommended post:
Simple calculator program in c using switch case
C program to print numbers using for loop [no comma at last]
Odd and even numbers program in c
Show Comments