# scalbn() function in C++

The scalbn() function is defined in the cmath header file. This function is used to calculate the product of given number x and FLT_RADIX raised to the power n.

Syntax:-

`float scalbn(float x, int n); `

or

`double scalbn(double x, int n); `

or

`long double scalbn(long double x, int n); `

or

`double scalbn(integral x, int n);  `

Parameters:- This method takes two parameters:

• x: This represents the value of significand.
• n: This represents the value of the exponent.

Return Value: This function returns the product of given number x and FLT_RADIX raised to the power n. with the help of formula:

`scalbn(x, n) = x * FLT_RADIXn`

Below programs illustrate the above function:-

Example 1:-

 `// C++ program to demonstrate ` `// example of scalbn() function. ` ` `  `#include ` `using` `namespace` `std; ` ` `  `int` `main() ` `{ ` `    ``int` `n = 7; ` `    ``int` `x = 5; ` `    ``int` `ans; ` ` `  `    ``ans = scalbn(x, n); ` `    ``cout << x << ``" * "` `         ``<< FLT_RADIX << ``"^"` `         ``<< n << ``" = "` `         ``<< ans << endl; ` ` `  `    ``return` `0; ` `} `

Output:

```5 * 2^7 = 640
```

Example 2:-

 `// C++ program to demonstrate ` `// example of scalbn() function. ` ` `  `#include ` `using` `namespace` `std; ` ` `  `int` `main() ` `{ ` `    ``int` `n = 7; ` `    ``double` `x = 3.9; ` `    ``int` `ans; ` ` `  `    ``ans = scalbn(x, n); ` `    ``cout << x << ``" * "` `         ``<< FLT_RADIX << ``"^"` `         ``<< n << ``" = "` `         ``<< ans << endl; ` ` `  `    ``return` `0; ` `} `

Output:

```3.9 * 2^7 = 499
```

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.

My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.