- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Programs for practice
Following C++ program ask to the user to enter the length and breadth of the rectangle to calculate and display the area and perimeter of the rectangle:
Source Code: Calculate Area and Perimeter of Rectangle
/* C++ Program - Calculate Area and Perimeter of Rectangle */ #include<iostream.h> #include<conio.h> void main() { clrscr(); int len, bre, peri, area; cout<<"Enter length and breadth of the rectangle :"; cin>>len>>bre; area=len*bre; peri=(2*len)+(2*bre); cout<<"Area = "<<area<<"\nPerimeter="<<peri; getch(); }Output
Enter length and breadth of the rectangle : 6 5 Area= 30 Perimeter = 22
Source Code: Calculate Area and Perimeter of Square in C++
/* C++ Program - Calculate Area and Perimeter of Square */
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int side, peri, area;
cout<<"Enter length of a side of square :";
cin>>side;
area=side*side;
peri=4*side;
cout<<"Area = "<<area<<"\nPerimeter="<<peri;
getch();
}
Output
Enter length of a side of square :4 Area=16 Perimeter = 16