C Program to Calculate the Power of a Number - Source Code, Output & Execution Flow

C Program to Calculate the Power of a Number

This tutorial explains c program to calculate the power of a number with C source code, sample output, and step-by-step execution flow.

#include <stdio.h>
int main() {
    int base, exp, i;
    long long result = 1;
    printf("Enter base and exponent: ");
    scanf("%d %d", &base, &exp);
    for (i = 1; i <= exp; i++) result *= base;
    printf("Result = %lld
", result);
    return 0;
}
Enter base and exponent: 3 4
Result = 81

In this program, the input is read first when required, the core logic is applied step by step, and the final result is displayed using printf(). Follow the execution flow beside the code to understand how each statement contributes to the output.

Sai Kishore Randhi, author
About the author

Sai Kishore Randhi

Embedded systems, VLSI, and chip design

Sai Kishore writes about embedded systems, VLSI, chip design, and the programming concepts behind modern hardware.

View LinkedIn profile ↗