# help with mathematical problem in C

• 09-10-2006
feelseez
help with mathematical problem in C
HI,

i am new to this forum and C language too. This actually is my first post. I need help with performing this mathematical operation in C.

B(X5 + Y3 + Z3)/7 where X,Y,Z are input data from the keyboard and B=4.

PLS, X5,Y3,Z3 implies X raised to the power of 5, Y raised to the power of 3 and Z raised to the power of 3.

Hope to hear from someone soon.

Thanks.
• 09-10-2006
Dave_Sinkula
multiplication is done with *, exponentiation with the function pow.
• 09-10-2006
Salem
> X5
Write
pow(X,5)

> B(X5
Would be
B * ( pow(x,5)

Just have
#include <math.h>
and see what you can come up with.
• 09-10-2006
dwks
You may also have to link with the math library; for GCC, add -lm to the end of the command line.
Code:

\$ cat 2pow20.c
#include <stdio.h>
#include <math.h>

int main(void) {
double x = 2.0, y = 20.0;

printf("%f\n", pow(x, y));

return 0;
}

\$ gcc -W -Wall -ansi -pedantic -O2 2pow20.c -o 2pow20 -lm
\$ ./2pow20
1048576.000000
\$