0% found this document useful (0 votes)
2 views

DSA-LAB_01(Recall C++ programming)

The document outlines a practical exercise focused on C++ programming, specifically demonstrating the use of classes and templates through a Rectangle class example. It includes pseudo code for class declaration and member functions, along with a main function to instantiate the class and invoke its methods. Additionally, it provides review questions and exercises for further practice in C++ programming.

Uploaded by

fareedasoomro41
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

DSA-LAB_01(Recall C++ programming)

The document outlines a practical exercise focused on C++ programming, specifically demonstrating the use of classes and templates through a Rectangle class example. It includes pseudo code for class declaration and member functions, along with a main function to instantiate the class and invoke its methods. Additionally, it provides review questions and exercises for further practice in C++ programming.

Uploaded by

fareedasoomro41
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Practical # 01

Objective:
Recall C++ programming and demonstrate C++ classes and templates using Code Blocks .
Theory:
In order to give a quick review of C++, Rectangle Class (class Declaration, Member function
definition, calling) is demonstrated in the lab.

Rectangle Class Pseudo Code:

Declare a class Rect, with data members: length, breadth, area, and perimeter.
Declare member functions to accept input and compute area and perimeters:
input(), ComputeArea(), ComputePeri(), Display()
Write a main function:
 instantiate the class by passing appropriate arguments to the constructor
 invoke ComputeArear(), ComputePeri() and Display() functions
Program in C++ :

Practical # 01 Page 1 of 2
OUTPUT:

Review Questions/ Exercise:


1. Write C++ program to add two integer values and print the output with descriptive
message.
2. Write C++ program to convert temperature from centigrade to Fahrenheit.
3. Write C++ program to build simple calculator using switch case statement.
4. Write a program to display the pattern as shown below:

5. Write a program to display the average of three numbers entered by the user by
creating a class named 'Average' having a function to calculate and display the
average..
_____________________________________________________________________________________________
___________________________________________________________________________________________
6. Write a program to display the sum, difference and product of two complex numbers
by creating a class named 'Complex' with separate functions for each operation
whose real and imaginary parts are entered by the user.
____________________________________________________________________________________________
___________________________________________________________________________________________

Name: _____
Roll #: _____
Date: _____

Subject Teacher
Remarks:

Practical # Page 2 of 2
01

You might also like