//Chapter 3 Exercise 1 Program //Header Files #include <iostream> using namespac
ID: 3649133 • Letter: #
Question
//Chapter 3 Exercise 1 Program//Header Files
#include <iostream>
using namespace std;
//Declaring constant
const double PI = 3.14159;
//Declaring variables for the cone
float diameter,radius,height;
float volume;
int main ()
{
//Now we input the diameter from the console
cout<< "Please enter the diameter of the cone.";
cin>> diameter;
//Now we input the height from the console
cout<< "Please enter the height of the cone.";
cin>> height;
//Now we find the radius by dividing the diameter of the cone by 2
radius = diameter/2;
//Now we calculate the volume with the following formula: 1/3 * PI * R * R * Height
volume = ((1/3) PI * (radius * radius * height));
//Now we can display the calculated volume of the cone on the console
cout<<" The Volume of the cone is:" <<volume<<endl;
//Used to pause the console display so we can see the calculated value
system ("pause");
return 0;
}
Explanation / Answer
the correct code is : #include using namespace std; int main () { //Declares pi, r, h, v. float r, h, v; float pi = 3.14159; //User inputs cone's radius. cout > r; //User inputs cone's height. cout > h; //Caculates the cone's volume. v = (1.0/3.0) * pi * (r*r) * h; //Output to screen. coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.