0% found this document useful (0 votes)
3 views3 pages

Practice Questions For Practical

The document contains a series of programming tasks in C++ focused on creating classes and inheritance. Each task requires the implementation of classes related to student information and shapes, including methods for calculating percentages, areas, and displaying information. The tasks involve creating objects and calling various member functions to demonstrate the functionality of the classes.

Uploaded by

farzanobaid13
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)
3 views3 pages

Practice Questions For Practical

The document contains a series of programming tasks in C++ focused on creating classes and inheritance. Each task requires the implementation of classes related to student information and shapes, including methods for calculating percentages, areas, and displaying information. The tasks involve creating objects and calling various member functions to demonstrate the functionality of the classes.

Uploaded by

farzanobaid13
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/ 3

Q 1:

Write a C++ Program to


● Create a class named Student_Basic_Info having public members name, age, and gender.
● Create a class named Student_Result_Info inherited from class Student_Basic_Info and
provide public members percentage, obtainedMarks, and totalMarks. Also, provide a
member function calculatePercentage to calculate the percentage and a member function
displayInfo to display the basic information and the percentage of the student.
Type the C++ code to create the object of the class and assign values to the public members
directly in the main function (name: "Ahmed", age: 15, gender: 'M', obtained marks: 400, total
marks: 500). Then call the function calculatePercentage to calculate the percentage and the
function displayInfo to print the basic information and percentage of the student.
Q2:
Write a C++ Program to
Create a class Shape with protected members base and height. Include a member function
getShapeInfo to get base and height. Derive a class Triangle from Shape with a member function
calculateArea to compute the area of the triangle and a member function displayInfo to display
the base, height, and area of the triangle.
Create the object of the class Triangle and assign values to the public members directly in the
main function (base: 10, height: 5). Then call the function calculateArea to calculate the area of
the triangle and the function displayInfo to print the base, height, and area of the triangle.
Q 3:
Write a C++ Program to
Create a class Student with public members percentage. Derive a class GradeCalculator from
Student with a member function calculateGrade to compute the grade of the student and a
member function displayInfo to display the percentage and grade of the student.
Create the object of the class GradeCalculator and assign a value to the public member directly
in the main function (percentage: 85). Then call the function calculateGrade to calculate the
grade of the student and the function displayInfo to print the percentage and grade of the student.
Q 4:
Write a C++ Program to
Create a class Student with a protected member percentage. Include a member function
getPercentage to input the percentage. Derive a class GradeCalculator from Student with a
member function calculateGrade to compute the grade of the student and a member function
displayInfo to display the percentage and grade of the student.
Create the object of the class GradeCalculator and call the function getPercentage to input the
percentage. Then call the function calculateGrade to calculate the grade of the student and the
function displayInfo to print the percentage and grade of the student.
Q 5:
Create a class Shape with protected members base and height. Include a member function
getShapeInfo to input these details. Derive a class Triangle from Shape with a member function
calculateArea to compute the area of the triangle and a member function displayInfo to display
the base, height, and area of the triangle.
Create an object of Triangle and call getShapeInfo, calculateArea, and displayInfo.
Q 6:
Write a C++ Program to
● Create a class named Student_Basic_Info having a function named getBasicInfo to get the
name, age and gender with protected members name, age and gender.
● Create a class named Student_Result_Info inherited from class Student_Basic_Info and
provide a member function getResultInfo to calculate the percentage with protected
members percentage, obtainedMarks and totalMarks. Also provide a member function
displayInfo to display the basic information and the percentage of the student.
Type the C++ code to create the object of the class and call the function getBasicInfo to get the
basic information of the student (name: "John Doe", age: 20, gender: 'M'), then call the function
getResultInfo to get the percentage of the student (obtained marks: 450, total marks: 500), and
also call the function displayInfo to print the basic information and percentage of the student.
Q7:
Write a C++ Program to
Create a class Shape with public members base and height. Derive a class Triangle from Shape
with a member function calculateArea to compute the area of the triangle and a member function
displayInfo to display the base, height, and area of the triangle.
Create the object of the class Triangle and assign values to the public members directly in the
main function (base: 15, height: 25). Then call the function calculateArea to calculate the area of
the triangle and the function displayInfo to print the base, height, and area of the triangle.
Q 8:
Write a C++ Program to
● Create a class named Student_Basic_Info having a function named getBasicInfo to get the
name, age and gender with protected members name, age and gender.
● Create a class named Student_Result_Info inherited from class Student_Basic_Info and
provide a member function getResultInfo to calculate the percentage with protected
members percentage, obtainedMarks and totalMarks. Also provide a member function
displayInfo to display the basic information and the percentage of the student.
Type the C++ code to create the object of the class and call the function getBasicInfo to get the
basic information of the student. Then call the function getResultInfo to get the percentage of the
student. Also call the function displayInfo to print the basic information and percentage of the
student.
Q 9:
Write a C++ Program to
Create a class Shape with protected member radius. Derive a class Circle from Shape with a
member function getRadiusInfo to input 5 radius (use an array) and a member function
displayInfo to calculate and display the area of each circle.
Create an object of Circle and call getRadiusInfo, and displayInfo.
Q 10:
Write a C++ Program to
Create a class Student with protected members name and rollNumber. Include a member function
getStudentInfo to input these details. Derive a class Student_Marks from Student with a member
function getMarksInfo to input marks in 5 subjects (use an array) and also calculate the
percentage.
Also create a member function displayInfo to display all details along with the percentage of the
student.
Create an object of Student_Marks and call getStudentInfo, getMarksInfo, and displayInfo.

You might also like