Linchakin

21st Aug - Power Function in C

 August 21, 2021     No comments   

This article will discuss the power function and its various examples in the C language. The power function is used to find the power of any given number. The power function is a predefined library function of the math.h header file, and we need to import the math.h header file in our program while using the pow() function. In other words, a pow() function is used to calculate the power of the base number (x) by raising the power of (y) as (xy).

For example, we take base as 2 and power as 5, the power of a number using the pow(2, 5) function to return a value as the 32. Similarly, we pass 3 as the base and 4 as the exponent number to raise the power of the base number using the pow(3, 4), which returns results as 81.

Power Function in C

Syntax

The pow() function has two integer arguments for raising the power of base value (x) by the exponent (y).

Parameters:

  1. x: The x variable represents the base value, whose power is to be calculated.
  2. y: The y variable represents the power or exponent value.

Program to find the power of an integer number using the pow() function

Let's consider an example to get the power of an integer number using the pow() function in the C programming language.

Program2.c

Output

Enter the base value from the user: 7
Enter the power value for raising the power of base: 5
7 to the power of 5 is = 16807

Program to calculate the power of double data value using the pow() function

Let's consider an example to demonstrate the pow() function using the double data values in the C programming language.

Program2.c

Output

  Enter the base value from the user: 2.9
Enter the power value for raising the power of base: 8.3
2.9 to the power of 8.3 is = 6884.99

Program to get the power of a number using a user-defined function

Let's consider an example to create a user-defined function to get the power of a number in the C programming language.

Program1.c

Output

Enter the base value: 25
Enter the power value: 6
25 to the power 6 is = 244140625

Program to get the power of a number using the recursion function and pow() function

Let's consider an example to find the power of a number using the recursion function and pow() function in the C programming language.

Program.c

Output

Enter the base value from the user 5
Enter the power value from the user 6
5 to the power of 6 is = 15625

Conclusion

A power function is used to find the power of any numeric data (int, float, double) using the pow() function. A power function has two arguments: the base number and the exponent number. The base number represents the power to be calculated, and the exponent defines the power of the base value.


Next Topic#

Adblock test (Why?)


You may be interested in:
>> Is a Chromebook worth replacing a Windows laptop?
>> Find out in detail the outstanding features of Google Pixel 4a
>> Top 7 best earbuds you should not miss

Related Posts:
>> Recognizing 12 Basic Body Shapes To Choose Better Clothes
>>Ranking the 10 most used smart technology devices
>> Top 5+ Best E-readers: Compact & Convenient Pen
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook

Related Posts:

  • Top 10 PC Games with the Best Graphics PC gaming has always been the premier platform for graphical fidelity. Arkham Knight could trade blows with any game on this list despite its age. Re… Read More
  • How GoPro Became a Victim of Bad Business Strategy GoPro stock prices went south after a promising NASDAQ debut in 2014. GoPro has been a no-growth company almost since its IPO. GoPro investors have n… Read More
  • Artstudio Pro 3.2.15 – Powerful painting and photo editing appby NMac Introducing Artstudio Pro, the most powerful painting and photo editing app available for both macOS and iOS . The successor to our famous Ar… Read More
  • StyleCLIPDraw: Text-to-Drawing Synthesis with Artistic Control Simply take a picture of the style you want to copy, enter the text you. generate, and this algorithm will generate a new picture out of it. The resu… Read More
  • Cumulus - Web Application Weakness Monitoring, It Would Be Working By Add Just 3 Codelines Cumulus is a service that helps you monitor and fix security weakness in realtime. The issues will be reported on web dashboard. It's very simple and… Read More
Newer Post Older Post Home

0 Comments:

Post a Comment


Copyright © 2025 Linchakin | Powered by Blogger
Design by Hardeep Asrani | Blogger Theme by NewBloggerThemes.com | Distributed By Gooyaabi Templates