C Programming Code Examples C > For Loops and While Loops Code Examples C program to find power of a number using for loop C program to find power of a number using for loop Write a C program to find power of a number using for loop. How to find power of a number without using built in library functions in C program. Logic to find power of any number without using pow() function in C programming. Logic to find power of any number Input base and exponents from user. Store it in two variables say base and expo. Declare and initialize another variable to store power say power = 1. Run a loop from 1 to expo, increment loop counter by 1 in each iteration. The loop structure must look similar to for(j=1; j<=expo; j++). For each iteration inside loop multiply power with num i.e. power = power * num. Finally after loop you are left with power in power variable. #include <stdio.h> int main() { int base, exponent; long long power = 1; int j; /* Input base and exponent from user */ printf("Enter base: "); scanf("%d", &base); printf("Enter exponent: "); scanf("%d", &exponent); /* Multiply base, exponent times*/ for(j=1; j<=exponent; j++) { power = power * base; } printf("%d ^ %d = %lld", base, exponent, power); return 0; }