Write a C++ program to find out the area of a rectangle whose length=6cm&breadth=12cm
Answers
Answer:
#include <iostream>
using namespace std;
int main()
{
int width, lngth, area, peri;
cout << "\n\n Find the Area and Perimeter of a Rectangle :\n";
cout << "-------------------------------------------------\n";
cout<<" Input the length of the rectangle : ";
cin>>lngth;
cout<<" Input the width of the rectangle : ";
cin>>width;
area=(lngth*width);
peri=2*(lngth+width);
cout<<" The area of the rectangle is : "<< area << endl;
cout<<" The perimeter of the rectangle is : "<< peri << endl;
cout << endl;
return 0;
}
Explanation:
C program :
Explanation:
#include <stdio.h>//Header file.
int main()//Main function definition.
{
float length=6,breadth=12,area;//Variable declaration.
area=length*breadth;//Expression to find the area.
printf("%f cm square",area);//print the value of area.
return 0;
}
Output :
- The above code will gives the result as "72".
Code Explanation:
- The above code is in C-language, which gives the area by the help of defined value which is defined in the question.
- The area is printed with the help of printf function.
Learn more :
- C-Language : https://brainly.in/question/610076