pow() and pow10() functions of math.h in C

In this article, we are going to learn about the two very useful pre-defined functions (pow() and pow10()) of math.h header file and see their functioning with their examples in C programming language.
Submitted by Manu Jemini, on March 17, 2018

In mathematics, it is very common to raise the value of a number to a certain power. Usually, this means that, multiply the number by itself, with given times.

To use the pow(a, b) function, all you need to do is to pass two parameters. The first parameter will define the number which needs to be raised to the power and the second parameter defines the magnitude of power. The Example given below, demonstrate it very clearly.

The pow10() is fast and easy. IT needs a number to be passed and this function will raise to the power of 10. This is easy If you need raising certain values to 10’s power.

Using these functions makes your program easy to understand, yet powerful in operational capabilities. These functions require a file math.h which should be included in the program before using these functions.

math.h - pow() function Example in C

#include <stdio.h>
//to use 'pow()' function
#include <math.h>

int main()
{
	// defining the type of variable
	float a, b, output;

	// taking inputs from user
	printf("Please enter both the numbers for calculating power");
	scanf("%f%f", &a, &b);

	// using the power function
	output= pow(a, b);

	// printing the result
	printf("The resulted output is : %.3lf\n", output);

	return 0;
}

Output

math.h pow() in c language

math.h - pow10() function Example in C

#include <stdio.h>
//to use 'pow10()' function
#include <math.h>

int main()
{
	// defining the type of variable and initiliziing them.
	int a = 2;
	float output;

	// using the function with power raised to 10.
	output= pow10(a);

	// printing the result
	printf("The resulted output of number's power raised to 10 is:  %f\n", output);

	return 0;
}

Output

math.h pow10() in c language



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.