Â
In this, we are going to see how to find Total Surface Area of Cylinder using C++ program.
The formula to calculate is,
Total Surface Area of Cylinder = 2 * π * radius(radius + height)
The Code given below can be used in Turbo C++ Compiler.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float area, radius, pi=3.142, height;
cout<<"This program is for Area of Cylinder\n";
cout<<"Enter the radius and height of the cylinder\n";
cin>>radius>>height;
//formula for area of cylinder is 2Ï€*radius*(raidus + height)
area = 2*pi*radius*(radius + height);
cout<<"The Area of the Cylinder with radius "<<radius<<" and height "<<height<<" is = "<<area<<" sq units";
getch();
}
The Code given below can be used in g++/gcc Compiler.
#include<iostream>
using namespace std;
int main()
{
float area, radius, pi=3.142, height;
cout<<"This program is for Area of Cylinder\n";
cout<<"Enter the radius and height of the cylinder\n";
cin>>radius>>height;
//formula for area of cylinder is 2Ï€*radius*(raidus + height)
area = 2*pi*radius*(radius + height);
cout<<"The Area of the Cylinder with radius "<<radius<<" and height "<<height<<" is = "<<area<<" sq units";
return 0;
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP