CSC425 Surface Area and Volume of A Cylinder
CSC425 Surface Area and Volume of A Cylinder
Lab Assignment
Write the pseudo-code, draw the flowchart and write a complete C++ program to compute
and display the surface area and volume of a cylinder.
surface_area = 2 x x r x (r + h)
Algorithm:
START
Readradius, height,
volume, surface_area,
pi=3.14159
Volume = pi*radius*radius*height
Surface_area= 2*pi*radius*(radius+height)
END
C++ Program:
/*
Name:
Sid# :
Course: CSC425
Group#:
Assign#: Assignment
Program Description: C++ program to compute and display the surface area
and volume of a cylinder.
*/
#include <cmath>
#include <iostream>
using namespace std;
int radius;
int height;
int volume;
int surface_area;
float pi=3.14159;
int main ()
{
cout<<" Enter radius"<<endl;
cin>>radius;
cout<<" Enter height"<<endl;
cin>>height;
volume= pi*radius*radius*height;
cout<<"Volume of cylinder is"<<volume<<endl;
surface_area= 2*pi*radius*(radius+height);
cout<<" Surface area of cylinder is "<<surface_area<<endl;
return 0;
}