Pages

Thursday, July 04, 2013

Write a program to find Volume of a cylinder in C++

Write a program to find the  Volume of a cylinder.
             Volume =  pi * h * r^2

Input:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
    #include <iostream.h>
    #include <conio.h>
    int main()
    {   float V, pi, h, r, r2,H ;
        cout << " Volume of a cylinder Formula: V = pi*h*r^2\n";
        cout << "Enter the height of cylinder?\n";
        cin  >> h;
        cout << "Enter the value of Radius?\n";
        cin  >> r;
        r2    = r * r;
        pi    = 3.1415;
        H     = r2*pi;    
        V     = H * h;
        cout << "\t\"The Volume of cylinder\" = " << V << " m^3 " << endl;
     getch();
     return 0; 
                     }

Output:


Volume of a cylinder Formula: V = pi*h*r^2
Enter the height of cylinder?
25
Enter the value of Radius?
8
        "The Volume of cylinder" = 5026.5 m^3

No comments:

Post a Comment