how would u write this in c? Define PI=3.14159265359 by using #define Compute th
ID: 3608144 • Letter: H
Question
how would u write this in c?Define PI=3.14159265359 by using #define
Compute the volume of the sphere with radius 3.0 and print the
radius and volume by using %.2f and %g,respectively.
Print a blank line.
Create the following table header
------------------------------------
x f(x) f'(x)
------------------------------------
Compute f(x) = x*x*x - x*x- 2.8*PI*x + 2.3*PI and itsderivative
f'(x)=3.0*x*x - 2.0*x -2.8*PI in the interval -1.0 <= x <=5.0
with the increment 0.25.
Print x, f(x), and f'(x) using %8.2f, %12.4e and %12.4f,respectively.
when u compile, its supposed to look something like this:
radius = 3.00 volume = .......
------------------------------------
x f(x) f'(x)
------------------------------------
-1.00 1.4022e+01 -3.7965e+00
..... .......... ...........
..... .......... ...........
..... .......... ...........
5.00 .......... ...........
can anyone help? i understand the the #include <stdio.h>
#define PI=3.14159265359
but dont really know where to go after. thanks.
Explanation / Answer
//Hope this will help you.. //Pls, Don't forget to rate this. #include #define PI 3.14159265359 float fx(float x) { float y; y= x*x*x - x*x- 2.8*PI*x + 2.3*PI; return y; } float f_x(float x) { float y; y= 3.0*x*x - 2.0*x -2.8*PI ; } int main(){ float x,r=3,area; area = 4.0*r*r*r/3; printf("Area of sphere is %.2f, %g ",area,area); printf("------------------------------------ "); printf(" x f(x) f'(x) "); printf("------------------------------------ "); for(x=-1;xRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.