# C ldexp() function

## C ldexp() function - Load exponent of a floating-point number

**Syntax:**

double ldexp(double x, int exponent)

The ldexp() function is used to calculate the value of x * (2a^{exp}).

**Parameters:**

Name | Description | Required /Optional |
---|---|---|

x | Floating-point value. | Required |

exponent | Integer exponent. | Required |

**Return value from ldexp()**

- returns the value of x * (2a
^{exp}).

**Example: ldexp() function**

The following example shows the usage of ldexp() function.

```
#include <math.h>
#include <stdio.h>
int main(void)
{
double x, y;
int p;
x = 3;
p = 2;
y = ldexp(x,p);
printf("%lf times 2 to the power of %d is %lf\n", x, p, y);
x = 3;
p = 3;
y = ldexp(x,p);
printf("\n%lf times 2 to the power of %d is %lf\n", x, p, y);
x = 1.5;
p = 5;
y = ldexp(x,p);
printf("\n%lf times 2 to the power of %d is %lf\n", x, p, y);
}
```

Output:

3.000000 times 2 to the power of 2 is 12.000000 3.000000 times 2 to the power of 3 is 24.000000 1.500000 times 2 to the power of 5 is 48.000000

**C Programming Code Editor:**

**Previous C Programming:** C frexp()

**Next C Programming: ** C log()

## C Programming: Tips of the Day

**What's the point of const pointers?**

const is a tool which you should use in pursuit of a very important C++ concept:

Find bugs at compile-time, rather than run-time, by getting the compiler to enforce what you mean.

Even though it does not change the functionality, adding const generates a compiler error when you're doing things you didn't mean to do. Imagine the following typo:

void foo(int* ptr) { ptr = 0;// oops, I meant *ptr = 0 }

If you use int* const, this would generate a compiler error because you're changing the value to ptr. Adding restrictions via syntax is a good thing in general. Just don't take it too far -- the example you gave is a case where most people don't bother using const.

Ref : https://bit.ly/33Cdn3Q

**Weekly Trends**- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- JavaScript functions Exercises
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises