Question:
Write a C++ program that displays prompts the user to enter the height and radius of a cylinder and calculate?
?
2011-04-16 20:33:06 UTC
This is homework for my C++ programming class and i can't figure it out
Five answers:
Jazka
2011-04-17 08:07:11 UTC
It's hard if you don't tell us what you're calculating, but from the information I'm going to deduce that you want the volume (pi*r^2*h).



Hope this is right:

#include

#include

using namespace std;



int main()

{

//pi*r^2*h



double pi = 3.14, r, h, volume;



cout << "Please enter the height." << endl;

cin >> h;



cout << "Please enter the radius." << endl;

cin >> r;



volume = pi * pow(r,2) * h;



cout << "The volume of the cylinder is " << volume << "." << endl;



system ("PAUSE");



return 0;

}
2016-12-03 05:46:52 UTC
if (num >= a million || num <=9999){ int n; n++; return num; } else { equipment.out.println("Please enter your extensive form lower back."); } ___ First, you will desire to logcal and then, no longer OR the circumstances. It would desire to be greater beneficial than 0 AND les than 9999 Secondly, the numbers would desire to be stored in an array (or field of a few sort). some thing like: int index; int numberarray[]; //enter num on a similar time as(num <> 9999) { if(num>0 && num < 10000) { numberarray[index] = num index++ } else { //output blunders message } } using an array you may carry as many numbers as needed, and the added computations would be calculated through looping by the array.
abbie
2016-09-15 10:34:13 UTC
That's a really good question, looking forward to going through the replies
Bob Bobbers
2011-04-16 20:38:33 UTC
πr^2H. What you want to do is get two variables from the user. then use the equation for the volume and store that answer in another variable which you would then print to the screen.
?
2011-04-16 20:40:16 UTC
you start with your headers and everything

when starting with the code you do something like that:

double height;

double radius;

cout<<"Enter height";

cin>>height;

cout<<"Enter radius";

cin>>radius;

double area;

area=3.14*radius*radius*height;

cout<<"The area of the cylinder is: "<
******************************************************************************


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...