Program to calculate area, perimeter and volume of a square.

Problem:

Write a program to calculate area, perimeter and volume of a square.

Solution:

#include<iostream.h>
#include<conio.h>
int main ()
{
cout<<endl<<endl<<endl;
float length=4;
float area,perimeter,volume;
area=length*length;
perimeter=4*length;
volume=length*length*length;
cout<<"the area of square having length:"<<length<<"is:"<<area<<endl;
cout<<"the perimeter of square having length:"<<length<<"is:"<<perimeter<<endl;
cout<<"the volume of square having length:"<<length<<"is:"<<volume<<endl;
getch();
}

Output:


Let me know in the comment section if you have any question.

Previous Post:
Program to calculate area, perimeter and volume of a sphere from radius input by user.
Next Post: