Computer Science, asked by itsmerakshit, 1 year ago

c++ program for a area of rectangle

Answers

Answered by AnanyaSrivastava999
0
#include<iostream.h> #include<conio.h> void main() { int length,breath,area_rec=0,parameter=0; clrscr(); cout<<"Enter Length and Breath of Rectangle: "; cin>>length>>breath; area_rec=length*breath; parameter=2*(length+breath); cout<<"\nArea of Ractangle: "cout<<area_rec; cout<<"\nParameters of Rectangle: "cout<<parameter; getch(); }
Answered by tiger009
0

Program for the area of the rectangle

Output:

Insert the length of the rectangle: 15.35

Insert the breadth of the rectangle: 12.36

Area of the rectangle: 189.726

Explanation:

#include <iostream>

using namespace std;

//main method

int main()  

{

 //declare the double type variables

 double length, breadth;

 //print message and get input from the user

 cout<<"Insert the length of the rectangle: ";

 cin>>length;

 //print message and get input from the user

 cout<<"Insert the breadth of the rectangle: ";

 cin>>breadth;

 //perform the calculation

 double area = length*breadth;

 //print the following result

 cout << "Area of the rectangle: "<<area;

}

The following are the description of the program.

  • Set the required header file and namespace then, declare the main method and inside the main function.
  • Declare the two double data type variables i.e., 'length' and 'breadth'.
  • Then, print the following message and get the input from the user in both variables.
  • Finally, we perform the following calculation and print the result with message.

Learn More:

https://brainly.in/question/15492365

Similar questions