<p><strong>Write a C program called vol.c, that computes the volume of a sphere
ID: 3637670 • Letter: #
Question
<p><strong>Write a C program called vol.c, that computes the volume of a sphere with a 10-meter radius,</strong><br /><strong>using the formula v=4/3πr3 . Declare π as a float variable in the main function as follows:</strong><br /><strong>float pi=3.14;</strong><br /><strong>The value for r have be entered from the keyboard using scanf as in previous practical problem</strong><br /><strong>Write the fraction 4/3 as (float)4/3 (or you can also write it as: 4.0f/3.0f) because 4 and 3 are</strong><br /><strong>integers and C truncates the result when two integers are divided.</strong><br /><strong></strong></p><p>Here is what I have written:</p>
<p>#include<stdio.h><br /><br />int main (void)<br />{<br />float pi=3.14;<br />int r;<br /><br />printf("Enter an integer: ");<br />scanf("%d",r);<br />volume = 4.0f/3.0f * pi * r * r * r;<br /><br />printf("Volume (cubic units): %d ", volume);<br /><br />return 0;<br />}</p>
<p><strong>When I compile using command: gcc vol.c it gives me compilation error.  Please help :) <br /></strong></p>
<p><strong>This is the error message I got when compiling:</strong></p>
<p><strong>vol.c: In function âmainâ:</strong><br /><strong>vol.c:11: error: âvolumeâ undeclared (first use in this function)</strong><br /><strong>vol.c:11: error: (Each undeclared identifier is reported only once</strong><br /><strong>vol.c:11: error: for each function it appears in.)</strong></p>
Explanation / Answer
# include # include using namespace std; int main () { double cubeVolume(double height); double h = pow(h,3); double sphereVolume(double radius); double PI = 3.14159; double r = pow(r,3); cout i; double result; if (i=='s') { cout > getradius; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.