C C++ Java Data Structure Python JavaScript CSS Ajax PL/SQL PHP Puzzles C programs C++ programs Java programs



Home » C programs » math.h header file functions

Function idexp() to raise a number to a given power in C






In this article, we are going to learn about the use Idexp() function of math.h header file and use it with the help of an example.
Submitted by Manu Jemini, on March 30, 2018

In mathematics, it is common to raise a number to certain power. Doing this in c can be very tricky, therefore using the idexp() function can be very useful as it will save you from complex code.

This function takes two parameters: a, and b. The First variable is the one which number needs to be multiplied with the raised value. Second number, tells us to power of the exponent.

For example, if a = 10.0 and b = 2, then if we pass idexp(a,b) then it will return 40.

Explanation:

    = a * 2b
    = 10 * 22
    = 10 * 4
    = 40



math.h - idexp() function Example in C

#include <stdio.h>
#include <math.h>

int main()
{
	// Defining variables
	float a,b,c;

	// Assigning value for getting floating point value
	a = 10.233;
	b = 3;

	// Calculating the ldexp of the a and b
	c = ldexp(a, b);

	// Displaying the result for the user
	printf("The calculated result is: %f \n\n", c);

	return 0;
}

Output

math.h idexp()  in c language







You may also be interested in...

C/C++ Tips and Tricks...

Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.


Comments and Discussions