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);
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:
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).