exponent of x using c c++

To calculate the exponent of a number x using C/C++, you can use the pow() function from the <cmath> library. The pow() function takes two arguments: the base number (x) and the exponent. It returns the result of raising the base number to the power of the exponent. Here's an example:

#include <iostream>
#include <cmath>

int main() {
    double x = 2.5;
    double exponent = 3;
    double result = pow(x, exponent);

    std::cout << "The exponent of " << x << " raised to the power of " << exponent << " is: " << result << std::endl;

    return 0;
}

In this example, we declare a variable x with a value of 2.5 and a variable exponent with a value of 3. We then use the pow() function to calculate the exponent of x raised to the power of exponent. The result is stored in the result variable.

Finally, we use std::cout to print the result to the console. The output would be:

The exponent of 2.5 raised to the power of 3 is: 15.625

The <cmath> library provides other mathematical functions as well, such as sqrt() for square root, sin() for sine, cos() for cosine, and many more. You can explore the library documentation for more information on these functions.