0

Does anyone know what I'm missing?

#include <stdio.h>

int main(void)
{
    float y = 2.55;
    float total = 3(y)(y)(y) - 5(y)(y) + 6;

    printf("%f\n", total);

    return 0;
}

1 Answer 1

1

You're thinking like a mathematician, not a programmer. You have to explicitly tell the compiler what operation to do.

float total = 3(y)(y)(y) - 5(y)(y) + 6;

will not work, but

float total = 3*(y)*(y)*(y) - 5*(y)*(y) + 6;

will work. Also, you could simplify it to

float total = 3*y*y*y - 5*y*y + 6;

If this answers your question, please accept the answer to remove your question from the unanswered question pool. Let's keep up on forum housekeeping. ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .