Raising a number to the power of n

visquis Posted messages 1 Status Member -  
ellana29460 Posted messages 805 Status Member -
La fonction qui permet de calculer la puissance d'un nombre est la fonction exponentielle.

1 answer

  1. ellana29460 Posted messages 805 Status Member 181
     
    ```html #include <math.h>

    pow(power, number);

    I believe the function is of type float. ```
    0
    1. [Dal] Posted messages 6122 Registration date   Status Contributor Last intervention   1 108
       
      Hi visquis, ellana29460,

      It's indeed
      pow
      , defined in
      math.h
      .

      But it's first the base and then the exponent. As for the type, the return value (the result) is a
      double
      , like its parameters.

      The prototype:

      double pow (double base, double exponent);

      http://www.cplusplus.com/reference/cmath/pow/

      If you need other types, and programming in C99 doesn't bother you, you can use the macro of the same name defined in tgmath.h.


      Dal
      0
    2. ellana29460 Posted messages 805 Status Member 181
       
      yes, but 5 minutes before the start of classes, I replied without taking the luxury of going to examine the prototype.
      sorry
      0