VOOZH about

URL: https://www.geeksforgeeks.org/c/power-of-number-in-c/

⇱ Power of a Number in C - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Power of a Number in C

Last Updated : 23 Jul, 2025

In this article, we will learn how to write a C program to calculate the power of a number (xn). We may assume that x and n are small and overflow doesn't happen.

👁 calculate power of a number in C

C Program To Calculate the Power of a Number

A simple solution to calculate the power would be to multiply x exactly n times. We can do that by using a simple for or while loop.


Output
8

Complexity Analysis

  • Time Complexity: O(n), to iterate n times.
  • Auxiliary Space: O(1)

Please visit the article Write the Program to Find pow(x,y) to know about more methods to calculate the power of a number.

Related Articles

Comment
Article Tags: