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

Lab 6

The document is a lab assignment sheet for a course on object-oriented programming. It instructs students to complete tasks involving recursive functions, including writing programs to generate square and triangle patterns recursively based on a user-entered number of rows. It provides guidelines for the tasks and assessments rubric for evaluating performance.

Uploaded by

Fazool Farigh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Lab 6

The document is a lab assignment sheet for a course on object-oriented programming. It instructs students to complete tasks involving recursive functions, including writing programs to generate square and triangle patterns recursively based on a user-entered number of rows. It provides guidelines for the tasks and assessments rubric for evaluating performance.

Uploaded by

Fazool Farigh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Electrical Engineering Department - ITU

CS152L: Object Oriented Programming Lab

Course Instructor: Nadir Abbas Dated:

Semester: Summer 2023


Lab Engineer: Usama Riaz
Session: Batch:

Lab 6. Solving Problems by Utilization of Recursive Functions

Name Roll number Obtained


Marks/100

Checked on: ____________________________

Signature: ____________________________
Objective
The objective of this lab is to observe the basic knowledge of programming in C++.
Equipment and Component
Component Value Quantity
Description
Computer Available in lab 1

Conduct of Lab
1. Students are required to perform this experiment individually.
2. In case the lab experiment is not understood, the students are advised to seek help from
the course instructor, lab engineers, assigned teaching assistants (TA) and lab
attendants.

Theory and Background

Recursive functions are functions that call themselves, allowing problems to be solved by
breaking them down into smaller subproblems. They consist of a base case that defines when the
recursion should stop and a recursive case that calls the function with modified parameters. By
dividing complex problems into smaller subproblems, recursive functions provide an elegant and
efficient solution. Care must be taken to ensure the base case is reached to avoid infinite
recursion. Recursive functions are commonly used for tasks such as calculating factorials,
traversing data structures, and solving mathematical problems.

Lab Task
Part A [Marks: 5]

Please follow the following steps before starting below tasks:


 Create function.h file for declaration of all functions
 Create function.cpp file to define define all declared functions.
 Create main.cpp file for driving code/call functions.

Note: Make a menu driven program (compulsory).


Part B: Implementation of Recursive Function [Marks: 17.5]
Write a program in C++ that uses recursion to generate and display a square pattern. The
program should prompt the user to enter the number of rows for the square and then use
recursion to generate and print the square pattern.

Enter the number of rows: 5

Pattern:

*****
*****
*****
*****
*****

Part C: Implementation of Recursive Function [Marks: 17.5]


Write a program in C++ that uses recursion to generate and display a triangle pattern. The
program should prompt the user to enter the number of rows for the triangle and then use
recursion to generate and print the triangle pattern.

Enter the number of rows: 5

Pattern:

*
**
***
****
*****

// Paste your code here


// Paste your output here
Assessment Rubric for Lab

Performance Max Obtained


Task CLO Description Exceeds expectation Meets expectation Does not meet expectation
metric marks marks
Executes without errors Executes without errors, user
Does not execute due to syntax
excellent user prompts, prompts are understandable,
errors, runtime errors, user
1. Realization good use of symbols, minimum use of symbols or
1 1 Functionality 40 prompts are misleading or non-  
of experiment spacing in output. Through spacing in output. Some
existent. No testing has been
testing has been completed testing has been completed
completed (0-19)
(35-40) (20-34)
Actively engages and Cooperates with other group
Distracts or discourages other
Group cooperates with other member(s) in a reasonable
2. Teamwork 1 3 5 group members from conducting  
Performance group member(s) in manner but conduct can be
the experiment (0-1)
effective manner (4-5) improved (2-3)
On Spot Able to make changes (8- Partially able to make
1 1 10 Unable to make changes (0-4)  
3. Conducting Changes 10) changes (5-7)
experiment Answered all questions (8- Unable to answer all questions
1 1 Viva/Quiz 10 Few incorrect answers (5-7)  
10) (0-4)
4. Laboratory
Comments are added and Comments are added and
safety and Code
1 3 5 does help the reader to does not help the reader to Comments are not added (0-1)  
disciplinary commenting
understand the code (4-5) understand the code (2-3)
rules
Excellent use of white
space, creatively organized Includes name, and
Poor use of white space
work, excellent use of assignment, white space
5. Data (indentation, blank lines) making
1 3 Code Structure 5 variables and constants, makes the program fairly easy  
collection code hard to read, disorganized
correct identifiers for to read. Title, organized work,
and messy (0-1)
constants, No line-wrap (4- good use of variables (2-3)
5)
Solution is efficient, easy A logical solution that is easy
6. Data A difficult and inefficient
1 4 Algorithm 20 to understand, and maintain to follow but it is not the most  
analysis solution (0-5)
(15-20) efficient (6-14)
Documentation
7. Computer
1 2 & GitHub 5 Timely (4-5) Late (2-3) Not done (0-1)  
use
Submissions
  Max Marks (total): 100 Obtained Marks (total):  

You might also like