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

BSCS Object Oriented Programming-LAB Spring 2021

The document outlines an examination for an Object Oriented Programming lab course, providing 8 programming questions that focus on concepts like functions, classes, structures, and arrays. Students are instructed to attempt no more than 4 questions, which involve tasks like temperature conversion, point coordinate calculation, operator overloading, and averaging numbers input into a float array.

Uploaded by

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

BSCS Object Oriented Programming-LAB Spring 2021

The document outlines an examination for an Object Oriented Programming lab course, providing 8 programming questions that focus on concepts like functions, classes, structures, and arrays. Students are instructed to attempt no more than 4 questions, which involve tasks like temperature conversion, point coordinate calculation, operator overloading, and averaging numbers input into a float array.

Uploaded by

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

PRESTON TERMINAL

UNIVERSITY EXAMINATION
Kohat – Islamabad – Lahore - Peshawar
Student Name: _______________________________Reg. No:____________________

Course Code: IS 3275


Course Title: Object Oriented Programming (LAB)
Program: BSCS
Semester: Spring 2021
This is a 2 hours practical examination and consists of programming questions only. You may
attempt not more than four questions.

Q1. Assuming there are 7.481 gallons in a cubic foot, write a program that asks the user to enter a number of gallons, and then
displays the equivalent in cubic feet.

Q2. Write a temperature-conversion program that gives the user the option of converting Fahrenheit to Celsius or Celsius to
Fahrenheit. Then carry out the conversion. Use floating-point numbers. Interaction with the program might look like this:
Type 1 to convert Fahrenheit to Celsius, 2 to convert Celsius to Fahrenheit: 1
Enter temperature in Fahrenheit: 70
In Celsius that’s 21.111111.

Q3. A point on the two-dimensional plane can be represented by two numbers: an x coordinate and a y coordinate. For example,
(4, 5) represents a point 4 units to the right of the vertical axis, and 5 units up from the horizontal axis. The sum of two
points can be defined as a new point whose x coordinate is the sum of the x coordinates of the two points, and whose y
coordinate is the sum of the y coordinates. Write a program that uses a structure called point to model a point. Define three
points, and have the user input values to two of them. Then set the third point equal to the sum of the other two, and display
the value of the new point. Interaction with the program might look like this:
Enter coordinates for p1: 3 4
Enter coordinates for p2: 5 7
Coordinates of p1+p2 are: 8, 11

Q4. Write a function called zeroSmaller() that is passed two int arguments by reference and then sets the smaller of the two
numbers to 0. Write a main() program to exercise this function.

Q5. Create a class that imitates part of the functionality of the basic data type int. Call the class Int (note different capitalization).
The only data in this class is an int variable. Include member functions to initialize an Int to 0, to initialize it to an int value,
to display it (it looks just like an int), and to add two Int values. Write a program that exercises this class by creating one
uninitialized and two initialized Int values, adding the two initialized values and placing the response in the uninitialized
value, and then displaying this result.

Q6. Create a class called employee that contains a name (an object of class string) and an employee number (type long). Include
a member function called getdata() to get data from the user for insertion into the object, and another function called
putdata() to display the data. Assume the name has no embedded blanks. Write a main() program to exercise this class. It
should create an array of type employee, and then invite the user to input data for up to 10 employees. Finally, it should print
out the data for all the employees.

Q7. Write a program that substitutes an overloaded += operator for the overloaded + operator in a program. This operator
should allow statements like s1 += s2; where s2 is added (concatenated) to s1 and the result is left in s1. The operator
should also permit the results of the operation to be used in other calculations, as in s3 = s1 += s2;

Q8. Write a program that reads a group of numbers from the user and places them in an array of type float. Once the numbers are
stored in the array, the program should average them and print the result. Use pointer notation wherever possible.

You might also like