# Thread: negative exponents (simple math prog)

1. ## negative exponents (simple math prog)

Hey all, i'm using an outdated book, but first of all there is no mention of using pow().

Code:
```/* Write a program that evaluates the following expression and displays the results (remember to use exponential format to display the result):
*
* (3.31 x 10^-8 x 2.01 x 10^-7) / (7.16 x 10^6 + 2.01 x 10^-8)
*/

#include <stdio.h>

int main(void)
{
double num;

num = (10 / 8 / 8 / 8 / 8 / 8 / 8 / 8 / 8);

printf("%f ", num);

return 0;
}```
Currently getting program to output (this is just a start on the calculation and not getting correct answer);

Code:
`0.000000`
Also, the previous question in book, here is my solution:

Code:
```/* 6. Write a program to evaluate the polynomial shown here:
*
* 3x^3 - 5x^2 + 6
* for x = 2.55
*/

#include <stdio.h>

int main(void)
{
float x = 2.55, num;

num = (3 * (x*x*x)) - (5 * (x*x)) + 6;

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

return 0;
}```
program output:

Code:
`23.231621`
Thanks...i understand I am learning how to use the parenthesis correctly. These questions are out of "Programming in C" third Edition by Stephen Kochan (2004). 2. In C , "10 / 8 / 8" is zero. While "10.0 / 8 / 8" is not zero.

Look up integer division for why.

Tim S. 3. Presumably the answer they are looking for is more like this. I have no idea what you are thinking trying to divide 10 by 8 eight times!
Code:
```#include <stdio.h>

int main()
{
printf("%.2e\n", (3.31e-8 * 2.01e-7) / (7.16e6 + 2.01e-8));
return 0;
}``` 4. Thanks john.c

My book states, "the %e characters are used the values of float or double in scientific notation". Originally Posted by john.c Presumably the answer they are looking for is more like this. I have no idea what you are thinking trying to divide 10 by 8 eight times!
Code:
```#include <stdio.h>

int main()
{
printf("%.2e\n", (3.31e-8 * 2.01e-7) / (7.16e6 + 2.01e-8));
return 0;
}``` Popular pages Recent additions #include, 10^-8, num;, output, program 