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

C Practical 3 Object Oriented Programming Using C

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

C Practical 3 Object Oriented Programming Using C

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

lOMoAR cPSD| 16345345

EXPERIMENT NUMBER –1. 3

Student’ Name – Vidisha Kharbanda UID – 22BAI71004


Class and Group – 109 A Semester – 2nd

AIM OF THE EXPERIMENT - Write a program to find the largest & smallest of threenumbers.
(Use inline function MAX and MIN)

FLOWCHART/ALGORITHM
ALGORITHM 1
• Start.
• Include the header file.
• Add namespace to your program.
• Define the two functions and pass the arguments to boththe functions.
• After each function apply the conditional statements whichwe will use
to find the largest and the smallest number.
• Start the main function.
• Call both the functions.
• Call them by call by value method.
• Print the output.
• Stop.

ALGORITHM 2

• Start.
• Include the header file
• create two classes 1 and 2.
• In both the classes create two variables num1 and num2which will be
of protected type.
• Initialize the variables with some value inside the member function.
• Between class one and two we will declare a function whichwill
display the original values given to the num1 and num2.
• Then apply the friend function which will swap the values
of num1 and num2.
• Now add the class2 to your code.
• Again apply the same friend function after the class2.
• Declare another function in which we will apply the logic toswap the
numbers.
• Start main function and create object of class 1 and 2respectively.
• Stop

SUBJECT NAME-Object Oriented Programming using C++ SUBJECT CODE-21CSH103


lOMoAR cPSD| 16345345

ALGORITHM 3

• Start.
• Include the header file.
• Add namespace to your program.
• Create a class named complex. Declare two variables privately.
• Declare a function publicly and pass two arguments to the function and
equalize them with the two variables we defined as privately.
• Add a member variable and pass an argument c to it.
• Add the formula to add the real part of the of both thecomplex numbers.
• Now declare another variable to show the different conditions of the
addition of numbers.
• Start the main function and create the objects and give thevalues to the
objects
• After that call the function set and display one by one.
• Print the output.

ALGORITHM 4
• Start.
• Include the header file.
• Add namespace to your program
• Define the maximum size of the hall by using the macro.
• Create the two classes guest and the hall.
• Declare the required variables. Inside the class.
• Declare the variables using static keyword also. 
• After that apply the logic so that our program can specify the order of first come
and first seat basis.
• Ask the user to input the names of all the guests.
• Using the scope resolution operator call the static variables.
• Now start the main function and call your class, apply the logic so that we can
print the required output.
• Print the output and Stop

PROGRAM CODE:

CODE 1
lOMoAR cPSD| 16345345

CODE 2

CODE 3
lOMoAR cPSD| 16345345

CODE 4

OUTPUT:

OUTPUT 2

OUTPUT 1

OUTPUT 4

OUTPUT 3

SUBJECT NAME-Object Oriented Programming using C++ SUBJECT CODE-21CSH103


lOMoAR cPSD| 16345345

ERRORS ENCOUNTERED DURING PROGRAM’S EXECUTION (Kindly jot down the compile timeerrors
encountered)
NONE

PROGRAM’S EXPLANATION (in brief):

Using C++ programming, we made program to find smallest and greatest number using inline function.
In the second program we swapped two numbers using friend function. In the third program we added
two complex number using classes and objects and in last program we made a list of people , only 50
People could book the table , we displayed the booked table with the persons name using static variables.

LEARNING OUTCOMES

• Remember the concepts related to fundamentals of C language, draw flowcharts and


write algorithm/pseudocode.

• Understand the way of execution and debug programs in C language.

• Apply various constructs, loops, functions to solve mathematical and scientific problem.

EVALUATION COLUMN (To be filled by concerned faculty only)

Sr. No. Parameters Maximum Marks


Marks Obtained

1. Worksheet Completion including writing learning 10


objective/ Outcome
2. Viva 8

3. Conduct 12

4. Total Marks 30

SUBJECT NAME-Object Oriented Programming using C++ SUBJECT CODE-21CSH103

You might also like