Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
3 views
Program 8.12 New
Uploaded by
zumar7956
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download now
Download
Save Program 8.12 New For Later
Download
Save
Save Program 8.12 New For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
3 views
Program 8.12 New
Uploaded by
zumar7956
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download now
Download
Save Program 8.12 New For Later
Carousel Previous
Carousel Next
Save
Save Program 8.12 New For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 4
Search
Fullscreen
ASSIGNMENT
Submitted By
Name Hafiz Umar Farooq
Class BBIT (evening)
Roll No F23-BBIT-5043
Subject OOP
Semester 3rd
Submitted To Prof. Faisal Zulfiqar
Write a program that uses three structures Dimension,
Results and Rectangle. The Dimension structure stores
length and width, Result structure stores area and
perimeter and Rectangle stores two variables of
Dimension and Results. The program declares a variable
of type Rectangle, inputs length, width, calculates area
and width and then displays the result.
#include <iostream>
using namespace std;
struct Dimension
{
double length;
double width;
};
struct Results
{ double area;
double perimeter;
};
struct Rectangle
{
Dimension dim;
Results res;};
int main()
{
Rectangle rect;
cout << "Enter the length of the rectangle: ";
cin >> rect.dim.length;
cout << "Enter the width of the rectangle: ";
cin >> rect.dim.width;
rect.res.area = rect.dim.length * rect.dim.width;
rect.res.perimeter = 2 * (rect.dim.length + rect.dim.width);
cout << "\nRectangle Details:\n";
cout << "Length: " << rect.dim.length << "\n";
cout << "Width: " << rect.dim.width << "\n";
cout << "Area: " << rect.res.area << "\n";
cout << "Perimeter: " << rect.res.perimeter << "\n";
return 0;
}
You might also like
Nafees 1
PDF
No ratings yet
Nafees 1
2 pages
Create A Class CalledExampleSeparateImplementationVeryImportant
PDF
No ratings yet
Create A Class CalledExampleSeparateImplementationVeryImportant
62 pages
Using Namespace Class
PDF
No ratings yet
Using Namespace Class
2 pages
Lab8 Lab Manual
PDF
No ratings yet
Lab8 Lab Manual
3 pages
#Include
PDF
No ratings yet
#Include
2 pages
Document
PDF
No ratings yet
Document
4 pages
Practical No 5S Oop Manual
PDF
No ratings yet
Practical No 5S Oop Manual
4 pages
Oop 3
PDF
No ratings yet
Oop 3
9 pages
6 Semester Oop Lab Report 1
PDF
No ratings yet
6 Semester Oop Lab Report 1
10 pages
Assignment
PDF
No ratings yet
Assignment
5 pages
CP2 Lab Tech 8
PDF
No ratings yet
CP2 Lab Tech 8
2 pages
Oops
PDF
No ratings yet
Oops
81 pages
Encapsulation Value of Classes and Objects Defining Classes: Data Encapsulation Procedural Encapsulation
PDF
No ratings yet
Encapsulation Value of Classes and Objects Defining Classes: Data Encapsulation Procedural Encapsulation
90 pages
Composition: Example
PDF
0% (1)
Composition: Example
13 pages
Assignment 1 OOP 1
PDF
No ratings yet
Assignment 1 OOP 1
6 pages
Oops Assignment-1
PDF
No ratings yet
Oops Assignment-1
16 pages
Lab 10
PDF
No ratings yet
Lab 10
5 pages
C++ Assignment 1
PDF
No ratings yet
C++ Assignment 1
19 pages
Bsee21036 Oop Lab 13
PDF
No ratings yet
Bsee21036 Oop Lab 13
6 pages
Question 3
PDF
No ratings yet
Question 3
2 pages
polymorphism
PDF
No ratings yet
polymorphism
2 pages
OOPS
PDF
No ratings yet
OOPS
44 pages
Class 12 20 Progs
PDF
No ratings yet
Class 12 20 Progs
41 pages
Lab Manual # 11: Title: C++ Structures Clo: Clo-1
PDF
No ratings yet
Lab Manual # 11: Title: C++ Structures Clo: Clo-1
13 pages
VIRTUAL FUNCTION
PDF
No ratings yet
VIRTUAL FUNCTION
4 pages
C++ Presentatn
PDF
No ratings yet
C++ Presentatn
16 pages
NMCP Class Test 1 Solution
PDF
No ratings yet
NMCP Class Test 1 Solution
3 pages
Practice Questions of CPP - Classes and Objects
PDF
No ratings yet
Practice Questions of CPP - Classes and Objects
9 pages
Assignment Csc402
PDF
No ratings yet
Assignment Csc402
11 pages
OOPS
PDF
No ratings yet
OOPS
5 pages
#Include #Define Using Namespace Int Int Double
PDF
No ratings yet
#Include #Define Using Namespace Int Int Double
4 pages
b22cs028 Rakesh Assignment-1
PDF
No ratings yet
b22cs028 Rakesh Assignment-1
11 pages
7 Setters and Getters
PDF
No ratings yet
7 Setters and Getters
2 pages
Assignment#2(Sardar Manzar Ali Khan _b24f0038ce003)
PDF
No ratings yet
Assignment#2(Sardar Manzar Ali Khan _b24f0038ce003)
30 pages
All Assgnments (1,2,3) Oop
PDF
No ratings yet
All Assgnments (1,2,3) Oop
37 pages
18
PDF
No ratings yet
18
4 pages
8 Setters and Getters 2
PDF
No ratings yet
8 Setters and Getters 2
3 pages
Assingment No.7: As A Virtual Function
PDF
No ratings yet
Assingment No.7: As A Virtual Function
2 pages
Experiment No 7 - Function Overloading in C++
PDF
No ratings yet
Experiment No 7 - Function Overloading in C++
6 pages
Itec 243 Lab 5
PDF
No ratings yet
Itec 243 Lab 5
2 pages
Assignment 1 C++
PDF
No ratings yet
Assignment 1 C++
5 pages
Mathematical Programming in C
PDF
No ratings yet
Mathematical Programming in C
3 pages
Computer Programing Fundamental
PDF
No ratings yet
Computer Programing Fundamental
14 pages
C++ Lab Solution
PDF
No ratings yet
C++ Lab Solution
37 pages
Practical No 4S OOP
PDF
No ratings yet
Practical No 4S OOP
5 pages
C++ Manual
PDF
No ratings yet
C++ Manual
36 pages
Untitled document
PDF
No ratings yet
Untitled document
4 pages
Simple C++ Programs
PDF
No ratings yet
Simple C++ Programs
7 pages
Daran 2
PDF
No ratings yet
Daran 2
11 pages
Structureassignment
PDF
No ratings yet
Structureassignment
2 pages
OOP LAB 2 Cs
PDF
No ratings yet
OOP LAB 2 Cs
6 pages
OOPS Report
PDF
No ratings yet
OOPS Report
58 pages
Function Overloading in C++
PDF
No ratings yet
Function Overloading in C++
15 pages
indianajones[1]
PDF
No ratings yet
indianajones[1]
11 pages
Lab 3 Exercises
PDF
No ratings yet
Lab 3 Exercises
4 pages
6 Classes 1 2
PDF
No ratings yet
6 Classes 1 2
2 pages
Act 1 Review of CPP Programming
PDF
No ratings yet
Act 1 Review of CPP Programming
6 pages
Lab 7_
PDF
No ratings yet
Lab 7_
6 pages
Building Telephony Systems with OpenSER
From Everand
Building Telephony Systems with OpenSER
Goncalves Flavio E.
No ratings yet
Introduction to Python Programming: Do your first steps into programming with python
From Everand
Introduction to Python Programming: Do your first steps into programming with python
Greytower Corp
No ratings yet