C++ Program
Write a C++ program using CodeBlocks to calculate the volume of a cylinder, for a
range of radii r.
Vcylinder = PI * (r^2) * h
Program Requirements
1. Your code should be properly commented to describe what you are doing.
2. The user should be prompted to enter the height (as an integer), the lowest radius value
(as a real number) and the highest radius value (also as a real number).
3. You must create and use a function to calculate the volume of the cylinder.
4. Create an array to store the values of the volume of the cylinder in ascending order for
radii from the lowest radius to the highest radius in 10 equal increments.
5. You must output the results for the volume for each of the radii from the array in
descending order.
You can use the following template to start writing your program:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
// your C++ code starts here
// wait until user is ready before terminating program
// to allow the user to see the program results
cout<< “Press Enter to continue…” <<endl;
cin.ignore(10, ‘n’);
cin.get();
return 0;
}
0 comments