-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path8.13.cpp
More file actions
27 lines (26 loc) · 911 Bytes
/
8.13.cpp
File metadata and controls
27 lines (26 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*Write a program that uses three structures Dimension,Result and Rectangle. The Dimension Structure stores length and width, Result structure stores
area and perimeter, and Rectangle structure stores two variables of Dimension and Result. The program declares a variable of type Rectangle, inputs
length,width, and calculates area and perimiter of rectangle and finally displays the result.*/
#include<iostream>
using namespace std;
struct Dimension{
float length,width;
};
struct Result{
float area,perimeter;
};
struct Rectangle{
Dimension t1;
Result t2;
}var;
int main(){
cout<<endl<<"Enter Length :";
cin>>var.t1.length;
cout<<endl<<"Enter Width :";
cin>>var.t1.width;
var.t2.area=var.t1.length*var.t1.width;
var.t2.perimeter=2*var.t1.length+2*var.t1.width;
cout<<"\n\tArea of Rectangle :"<<var.t2.area;
cout<<"\n\tArea of Perimeter :"<<var.t2.perimeter;
return 0;
}