C++ Lab Worksheet 5.1
C++ Lab Worksheet 5.1
C++ Lab Worksheet 5.1
1
STUDENT’S NAME – Aryaman Sharma
SEMESTER – 2
TOPIC OF EXPERIMENT –
Write a program that takes information about institute staff information for
3) Typist code, name, speed and daily wages and displays it using hierarchal
inheritance.
ALGORITHM –
START
Create a member function getstaff() and print the details and accept the input
Create a member function getdata() and print the details and accept the input
Create a member function void create()and print the details and accept the
Create a member function gettypist()and print the details and accept the input
STOP.
In this program we have to enter the information of institute staff by creating class
staff and by using public and protected specifiers and different member functions and
display it using hierarchical inheritance
OUTPUT –
EXPERIMENT NUMBER –Practical 5.1.2
STUDENT’S NAME – Aryaman Sharma
SEMESTER – 2
TOPIC OF EXPERIMENT –
ALGORITHM –
START
Create a member function getmarks() and putmarks() print the details and
accept the input from the user by using public access specifier.
Create a member function getscore() and putscore() to print the details and
accept the input from the user by using public access specifier.
total=part1+part2+sports
Implement all the member functions with the object of this class to print the
details.
Call all the member functions in main function using dot(.) obj.
End.
PROGRAM CODE –
ERRORS ENCOUNTERED DURING PROGRAM’S EXECUTION –
In this program we have to create a class student having student uid and
getnumber(),putnumber() as member functions to get the values and display it and
then derive a class test having marks in different subjects and getmarks() and
putmarks() as member functions to get and display the values. After that derive
another class sports from student class having sports score and getscore(),
putscore() as member functions to get and display the values. And then derive a
class result from test and sports class and define a function display() to calculate
total marks. After that call all these member functions in main function and print
the details by using dot(.) operator.
OUTPUT –
EXPERIMENT NUMBER –Practical 5.1.2
STUDENT’S NAME – Aryaman Sharma
SEMESTER – 2
TOPIC OF EXPERIMENT –
WAP to illustrate how the constructors are implemented and the order in which
they are called when the classes are inherited. Use three classes named alpha,
beta, gamma such that alpha, beta are base class and gamma is derived class
inheriting alpha &beta. Pass four variable to gamma class object which will further
send one integer variable to alpha(),one float type variable to beta().Show the
order of execution by invoking constructor of derived class.
ALGORITHM –
START
Initialize a variable x.
Pass the values in class alpha and print the details.
Create a member function show_x() and accept the input from user and print
the details.
Create a member function show_y() and accept the input from user and print
the details.
Create a member function show_mn() and accept the input from user and print
the details.
Call all the member functions in the main function using dot(.)g.
End.
PROGRAM CODE –
ERRORS ENCOUNTERED DURING PROGRAM’S EXECUTION –
In this program we have to create three classes named alpha, beta, gamma such
that alpha, beta are base class and gamma is derived class inheriting alpha &beta.
Pass four variable to gamma class object which will further send one integer
variable to alpha(),one float type variable to beta().Show the order of execution by
invoking constructor of derived class.
OUTPUT –
LEARNING OUTCOMES
Identify situations where computational methods would be useful.
Approach the programming tasks using techniques learnt and write pseudo-code.
Choose the right data representation formats based on the requirements of the problem.
Use the comparisons and limitations of the various programming constructs and choose
the right one for the task.