The document provides the code for a C++ program to calculate the volume of a cylinder given its radius and height. The program defines pi as 3.14, sets the radius to 5 and height to 12, uses the formula for volume of a cylinder (V = πr^2h) to calculate the volume, and prints the result, which is 942.
Python Notes for mca i year students osmania university.docx
Write a program to compute the volume V of a cylinder of radius r and (1).docx
1. Write a program to compute the volume V of a cylinder of radius r and height h. (Recall that V =
r2h.) in c++ let r = 5 and h=12 and pi=3.14
Solution
Volume of the cylinder is r 2 h
PROGRAM:
#include <iostream>
#include <cmath>
using namespace std;
const float pi=3.14; /* defining the constant value of pi and later using it in the program */
int main()
{
int r=5,h=12;
float volume;
volume = pi * pow(r,2) * h; /* pow(x,y) is a function used to calculate the value of x y and
here it is used to calculate r 2 */
cout<<" Volume of the cylinder is "<<volume;
}
OUTPUT: Volume of the cylinder is 942