Object Oriented Programming Lab
Laboratory Manual
Aasma Abdul Waheed – Associate Lecturer
Faculty of Information Technology (FOIT & CS)
University of the Central Punjab, Lahore
CSCP2023 Object Oriented Programming Lab Fall 2024
Contents
Preferred Tool(s):..........................................................................................................................2
Text/Reference Book(S)................................................................................................................2
General Instructions:....................................................................................................................2
Instructors:...................................................................................................................................2
Lab Manual 01..............................................................................................................................3
Task 01: Calculate Total Marks.........................................................................................................5
Task 02: Swap Two Arrays...............................................................................................................5
Task 03: Copy only Vowels from String...........................................................................................5
Task 04: Rotate Array Elements by Halves.......................................................................................5
Task 05: File Handling......................................................................................................................6
Lab Assessment Rubric.................................................................................................................7
Aasma Abdul Waheed – Associate Lecturer
FOIT & CS
1
CSCP2023 Object Oriented Programming Lab Fall 2024
Course Objectives:
This module will provide the students with a solid theoretical understanding of, as well as practical
skills in, object-oriented programming. Practical skills will be learnt using the C++ programming
language. The primary aim of the module is to enable the students to tackle complex programming
problems, making good use of the object-oriented programming paradigm to simplify the design and
implementation process. Laboratory sessions and tutorials will be provided to encourage acquisition
of practical problem-solving skills.
Preferred Tool(s):
Microsoft Visual Studio 2022, C++
Text/Reference Book(S):
C++ How to Program by Deitel and Deitel, 8th Edition.
C++ Programming Language, 4th Edition by Bjarne Stroustrup.
Effective C++: 55 Specific Ways to Improve Your Programs and Designs by Scott Mayers,
3rd Edition
Effective Modern C++ by Scott Mayers
General Instructions:
In this Lab, you are NOT allowed to discuss your solution with your colleagues, even not
allowed to ask how s/he is doing, this may result in negative marking. You can ONLY
discuss with your Lab Instructor.
Viva for each task will be taken and considered as a performance.
Your Lab Instructor will be available in the Lab for your help. Alternatively, you can visit
your Lab Instructor in office hours (shared on portal) or send your queries via email to one
of the followings.
Instructors:
Lab Instructor Aasma Abdul Waheed [email protected]
Course Instructor Dr. Ahmad Shabbar Kazmi [email protected]
Course Coordinator Dr. Abbas Khalid [email protected]
Aasma Abdul Waheed – Associate Lecturer
FOIT & CS
2
CSCP2023 Object Oriented Programming Lab Fall 2024
Lab Manual 01
Aasma Abdul Waheed – Associate Lecturer
FOIT & CS
3
CSCP2023 Object Oriented Programming Lab Fall 2024
Lab 01
Topic Revision Lab
The basic purpose of this laboratory is revision of some preliminary concepts of C++
that has been covered in the course of Introduction to Computing and Programming
Fundamentals. Its objective is to:
Objective
Recall students previously learned basic concepts.
Revision of arrays and functions.
Understanding problem statements and designing an appropriate solution.
Instructions:
Indent your code and comment your code.
Use meaningful variable names.
Plan your code carefully on a piece of paper before you implement it.
Use three filing system for your code. Make two source .CPP files and one header .h file.
Write the code in separate files (.h, .cpp), and call functions from main.cpp. Ensure that file
names are in lowercase.
Name of the program should be same as the lab number following your registration number.
i.e. the program name should be LAB1_L1F23BSCS0123.cpp.
You are restricted to write your registration number in comments at very first line of your
each file, for example //L1F23BSCS0123.
Ensure your all coding (.CPP, .H)/solution files are in the zipped folder at the time of
submission.
Make a menu for all task and use naming conventions for example Task1() etc. so that user
would be able to execute specific task/ question from menu according to his/her own choice.
void main() is not allowed. Use int main()
You are not allowed to use system("pause")
You are not allowed to use any built-in functions
You are required to follow the naming conventions as follow:
o Variables: firstName; (no underscores allowed)
o Function: getName(); (no underscores allowed)
Use of ChatGPT, copied from any internet or other source will result in 0 marks in all task.
Without viva your lab will not be evaluated.
Understanding of the question is part of the evaluation.
Students are required to complete the following tasks in the lab timings.
Aasma Abdul Waheed – Associate Lecturer
FOIT & CS
4
CSCP2023 Object Oriented Programming Lab Fall 2024
Lab Tasks
Task 01: Calculate Total Marks
Objective: Introduce array input/output and basic arithmetic operations. Write a C++
program that:
Defines an array of size "5".
Takes marks of five subjects as input from the user and stores them in the array.
Pass the array to a function that calculates the total sum of marks.
Display the total sum on the console.
Task 02: Swap Two Arrays
Objective: Learn to work with pointers and arrays. Create a C++ program that:
Takes two arrays of size 3, with integers as input from the user.
Swap the values between the two arrays using pointers.
Display the arrays after swapping.
Task 03: Copy only Vowels from String
Objective: Learn string manipulation by focusing on specific characters (vowels).
Write a non-returning function copyVowels() that takes two char* parameters: one for the
destination and one for the source. The function should copy only the vowels from the source
string to the destination string.
void copyVowels(char*& dest, const char* src);
Note: You are not allowed to use any built-in functions.
Task 04: Rotate Array Elements by Halves
Objective: Implement advanced array manipulations through specific rotations.
Write a function that accepts an integer array and its size. The function should divide the
array into two halves and rotate each half separately by 1 position to the right. For example:
Initial array: {1, 2, 3, 4, 5, 6}
Modified array: {3, 1, 2, 6, 4, 5}
Aasma Abdul Waheed – Associate Lecturer
FOIT & CS
5
CSCP2023 Object Oriented Programming Lab Fall 2024
Task 05: File Handling
Objective: File Handling
Create a file named data.txt with a sequence of integers as shown below. Write a
program that reads these integers one by one and separates them into two dynamic arrays:
lowArray for numbers less than or equal to 5, and highArray for numbers greater than 5.
As the arrays fill up, dynamically increase their size (regrow). Stop processing the integers
when you encounter -1 in the file. Once all valid numbers are processed, find the maximum
value from each array and write these two maximum values to a new file output.txt in
the following format:
data.txt: 1 5 6 2 3 4 5 8 2 0 1 3 9 5 6 -1 5 6 8 3 5 6 4 8
Note:
Do not store all numbers in a single array initially.
Regrow the arrays as needed while processing the data.
After processing, only the maximum values from both arrays should be written to the
output file.
Aasma Abdul Waheed – Associate Lecturer
FOIT & CS
6
CSCP2023 Object Oriented Programming Lab Fall 2024
Registration #: Name & Section: Date:
Lab Assessment Rubric
Exemplary (Excellent) Acceptable (Good) Developing (Satisfactory) Unsatisfactory Student
Dimension Score out of
10 9‐7 6‐5 4‐0 10 Marks
Submission Report is submitted on time and in correct format. Report is submitted on time with slight Report is submitted on time in incorrect Report is not submitted.
incorrect format. format.
Overall Report is complete, well written, and organized Report is complete, briefly written, and Report is mostly complete, loosely Report is incomplete, sloppy, and/or
Impression appropriately with additional elements that enhance it. Task organized. Lacks additional elements. written, and fairly organized. Basic disorganized.
of Lab titles and output screenshots are included. Purpose for each Task titles and output screenshots are documentation including descriptions of No documentation included.
Report/ Task concept, input requirements and output results is noted. included. Purpose for each concept, all concepts. Specific purpose is noted for No task titles, no output screenshots,
Completion input requirements and output results is each concept. Task titles and output poor
noted. screenshots are formatting.
included and good formatting.
Algorithm/ Efficient and effective logic used with clear steps and well- Logic is correct but could be optimized Basic logic is used, but lacks efficiency or Logic is unclear, inefficient, or
Logic planned design patterns or better structured clarity in places incorrect in multiple areas
Coding Use of proper indentation, whitespace, line length, Missing some of whitespace, line Poor use of whitespace, line length, No standard followed.
Standards wrapping, comments and references. length, wrapping, comments or wrapping, comments and references.
references.
Compilation, Program compiles with no errors and no warnings. Program compiles with no errors Program compiles with no errors and lots Program fails to compile. Does not
Execution, Executes without errors, excellent user prompts, good use of and some warnings. Executes of warnings. execute due to errors.
and Results symbols, and spacing in output. without errors. Executes without errors. User prompts are misleading
Thorough and organized testing has been completed and User prompts are understandable, User prompts are understandable, or non‐ existent.
output from minimum use of symbols or spacing in minimum use of symbols or spacing in No testing has been d.
test cases is included. output. Most of the testing has been output.
completed. Some testing has been
completed.
Debugging, Debugging, profiling, and optimization are Debugging and profiling are performed. Only debugging and profiling is No debugging, No profiling.
Profiling, and performed. Slight optimization is performed. No optimization. No
Optimization also performed. optimization.
Viva/Oral Demonstrates deep understanding of implemented Good understanding but struggles with Basic understanding with notable gaps or Unable to explain the logic,
Evaluation code, OOP principles, and can explain all choices minor concepts or explaining specific unclear explanations OOP concepts, or
made choices implementation effectively
Marks: /7 =
Teacher Remarks and Signature:
Aasma Abdul Waheed – Associate Lecturer
FOIT & CS