double pow (double x, double y) -- problems

This is the code and I'm wondering why line 14: a = ... and line 16: b = ... is wrong.

This is the first time I've tried to use this. Please help me.

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

// The link and how the double pow is used.
//
// http://www.nextdawn.nl/c-reference/pow.php
//
// double pow(double x, double y); 

int main (void)
{
    double x = 2.55;
    double a, A = 3.00, b, B = 2.00;
    double Z = 3 * a - 5 * b + 6;
    
    a = double pow (double x, double A);
    
    b = double pow (double x, double B);
    
    printf ("3x^3 - 5x^2 + 6 = %.2lf\n", Z);
    
    return 0;
}

try this:

$ cat x.c
#include <stdio.h>
#include <math.h>

// The link and how the double pow is used.
//
// http://www.nextdawn.nl/c-reference/pow.php
//
// double pow(double x, double y);

int main (void)
{
    double x = 2.55;
    double a, A = 3.00, b, B = 2.00;
    double Z ;

    a = pow (x, A);

    b = pow (x, B);
    Z = 3 * a - 5 * b + 6;

    printf ("3x^3 - 5x^2 + 6 = %.2lf\n", Z);

    return 0;
}
$ gcc x.c -lm -o x
$ ./x
3x^3 - 5x^2 + 6 = 23.23
$

That was very helpful and I understand what I did wrong the first time.

Thank you very much.

:slight_smile: