KEMBAR78
Discrete Structure Lab Manual Final-1 | PDF | C++ | Computer Program
0% found this document useful (0 votes)
10 views140 pages

Discrete Structure Lab Manual Final-1

The document is a laboratory manual for a Discrete Structures course at the University of Lahore, detailing guidelines for laboratory procedures, safety precautions, and assessment rubrics for students. It outlines the course learning outcomes, mapping to program learning outcomes, and lists various experiments related to C++ programming. Additionally, it includes evaluation logs and sample tasks for students to complete in the lab.
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)
10 views140 pages

Discrete Structure Lab Manual Final-1

The document is a laboratory manual for a Discrete Structures course at the University of Lahore, detailing guidelines for laboratory procedures, safety precautions, and assessment rubrics for students. It outlines the course learning outcomes, mapping to program learning outcomes, and lists various experiments related to C++ programming. Additionally, it includes evaluation logs and sample tasks for students to complete in the lab.
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/ 140

Discrete Structures

CS09202|11

Laboratory Manual

Student Copy
Fall 2024

Submitted to:
Miss Hafiza Mariyum Mustafa
Lecturer

Submitted by:
Shahzaib Khan , Moiz Iqbal
Name:
70176698, 70173907
Registration Number:

Program: Information Engineering Technology

The University of Lahore


1-km, Defense Road, Bhupatian Chowk, Off Raiwind Road, Lahore
The University of Lahore Department of Technology

Guidelines for Laboratory Procedure


● Before starting a new lab, you must always read the laboratory manual for that
experiment and the instructor will discuss the experiment with you.

● Attachments must be made for laboratory experiment done in the class.

● Make sure that your observation for previous week experiment is evaluated by the
faculty member and your have transferred all the contents to your record before entering
to lab.

● At the beginning of the class, if the faculty or the instructor finds that a student is not
adequately prepared, they will be marked as absent and not be allowed to perform the
experiment.

● Please actively participate in class and don’t hesitate to ask questions.

● Please utilize teaching assistants fully. To encourage you to be prepared and to read the
lab manual before coming to the laboratory, unannounced questions may be asked at
any time during the lab.

● Maintain silence, order and discipline inside the lab. Don’t use cell phones inside the
laboratory.

● Report to the instructor if you find equipment that is out of order or you break
something.
The University of Lahore Department of Technology

Safety Precautions

This is a partial list of basic safety precautions to use when working on a computer:

● Remove your watch and jewelry and secure loose clothing.


● Turn off the power and unplug equipment before performing service.
● Take a note of all the exits in the room, and also take note of the location of
fire extinguishers in the room for the sake of fire safety.
● Try not to type continuously for extremely long periods.
● Look away from the screen once in a while to give your eyes a rest.
● Do not touch any exposed wires or sockets.
● Do not attempt to open any machines, and do not touch the backs of machines
when they are switched on.
● Do not spill water or any other liquid on the machine, in order to maintain
electrical safety.
● Turn off the machine you were using, when you are done using it.
● Do not access external devices without scanning them for computer viruses.
● Ensure that the temperature in the room stays cool, since there are a lot of
machines inside a lab, and these can overheat easily.
● Try not to touch any of the circuit boards and power sockets when something
is connected to them and switched on.
● Always maintain an extra copy of all your important data.
The University of Lahore Department of Technology

Safety Undertaking

I have read all of the above, and I agree to conform to its contents.

Name: Shahzaib Khan , Moiz Iqbal

Registration No.: 70176698, 70173907

Student Signature:

Date:

Lab Instructor:
The University of Lahore Department of Technology

Laboratory Work Assessment Rubrics


Sr. Performance
Excellent (5) Good (4) Average (3) Fair (2) Poor (1)
No. Indicator
Student knows very
Student knows all Student knows most
Student knows few of little about the Student has poor
the related of the related
the related concepts related concepts understanding of the
concepts about the concepts about the
about the theoretical about the related concepts about
Theoretical theoretical theoretical
background of the theoretical the theoretical
background of the background of the
1 knowledge experiment and background of the background of the
experiment and experiment and
10% partially rephrase experiment and experiment and unable
rephrase those partially rephrase
those concepts in poorly rephrase to rephrase those
concepts in written those concepts in
written and oral those concepts in concepts in written
and oral written and oral
assessments written and oral and oral assessments
assessments assessments
assessments

Application Application Application does


Application compiles with few compiles and not compile or
Application runs
compiles with no or no warnings. runs without compiles but
Application smoothly and
warnings. Robust Consideration crashing. Some crashes.
2 Functionality operation of the
operation of the given to unusual attempt at Confusing. Little
10% application runs
application, with conditions with detecting and or no error
efficiently
good recovery. reasonable correcting detection or
recovery errors. correction.

The program works


The program
and produces the The program
works very
The program works correct results and produces correct The program is
Specifications efficiently and
3 and meets some of displays them results but does not producing incorrect
10% meets all of the
the specifications. correctly. It also display them results.
required
meets most of the correctly.
specifications.
other specifications.

Provide complete Provide complete Provide partially


Level of and logical and logical answers correct and logical Provide very few
understanding answers based based upon accurate answers based upon and illogical Provide no answer to

4 of the learned upon accurate technical content to minimum technical answers to the the questions asked by
skill technical content the questions asked content to the questions asked by examiner.

10% to the questions by examiner with questions asked by examiner.


asked by examiner few errors examiner
The code is fairly
The code is Some parts of the The code is poorly
Readability easy to read. The
exceptionally well Most of the code code require organized and very
and code could be reused
5 organized and couldbe reused in change before they difficult to read and
Reusability as a whole or each
very easy to other programs. could be reused in not organized for
10% class could be
follow and reused other programs. reusability.
reused.
The University of Lahore Department of Technology

Some attempt at
Little attempt at
Well-designed Good data layering data. Some Very poor attempt and
layering data.
Object classes with good abstraction and some generalization of missing code. Code is
Missing, duplicate
Oriented data abstraction data layering. Good interface evident but maintenance
6 or not useful class
Design and layering. Code set of operations missed opportunity. headache. No OOP
interface. Some
10% is highly provided. Little Code can be language feature is
OOP language
maintainable duplications maintained with used
feature is used
significant effort

1. Responds well,
quick and very
1. Generally
accurate all the 1. Not much
Responsive and 1. Generally 1. Non-Responsive
time. Responsive and
accurate most of the Responsive and and inaccurate all the
Responsiveness 2. Effectively uses accurate most of
times. accurate few times. times.
to Questions/ eye contact, the times.
7 2. Maintains eye 2. Some eye contact, 2. No eye contact and
Accuracy speaks clearly, 2. Uses eye contact
contact, speaks speaks clearly and unable to speak
10% effectively and ineffectively and
clearly with suitable unclearly in different 3. Dresses
confidently using fails to speak
volume and pace. portions. inappropriately
suitable volume clearly and audibly
and pace.

Some part of the code


The code is The code is fairly
is efficient and other
extremely efficient efficient without The code is brute The code is huge and
Efficiency part of the code is not
8 without sacrificing sacrificing force and appears to be patched
10% understandable and
readability and readability and unnecessarily long together
work properly
understanding understanding

The code was


The program was The program was The program was The code was
Delivery delivered within a
9 delivered in time delivered in Lab delivered within the delivered more than 2
10% day after the due
during lab. before the end time. due date. days overdue.
date.
Student has
Student has Student has little Student has little
sufficient Student has no
sufficient knowledge knowledge of the knowledge of the
Awareness of knowledge of the knowledge of the
of the laboratory laboratory safety laboratory safety
Safety laboratory safety laboratory safety
10 safety SOPs and SOPs and protocol SOPs and protocol
Guidelines SOPs and protocol SOPs and protocol
protocol and is and is Partially and is non-
10% and is fully and is non-compliant
Partially compliant compliant to the compliant to the
compliant to the to the guidelines
to the guidelines guidelines guidelines
guidelines
The University of Lahore Department of Technology

Lab’s Course Learning Outcomes

Course Title: Discrete Structures

Course Code: CS09202

Instructor: Hafiza Mariyaum

Designation: Lecturer

E-mail: mariyaum.mustafa@tech.uol.edu.pk

Students will be able to:


CLO 3:State key concepts of Discrete Structures and its core components,including conditions,loops,functions and
recursive functions.(P2,PLO4)
CLO4:Construct Discrete Structtures models and solutions by applying knowledge and unnderstanding of
sets,searching algorithms, sorting algorithms,functions and matrices to solve simple problems. (P4,PLO5)

Mapping of Course Learning Outcomes (CLO) to Program Learning Outcomes (PLO)


Graduate Attributes

Course CLOs/ PLO 1 PLO2 PLO3 PLO4 PLO5 PLO6 PLO7 PLO8 PLO9 PLO 10 PLO 11 PLO 12
Code

x
CS09202 CLO 3

x
CS09202

PLO1: Engineering Knowledge PLO8: Ethics


PLO2: Problem Analysis PLO9: Individual and Team Work
PLO3: Design/Development of Solutions PLO10: Communication
PLO4: Investigation PLO11: Project Management
PLO5: Modern Tool Usage PLO12: Lifelong Learning
PLO6: The Engineer and Society
PLO7: Environment and Sustainability
The University of Lahore Department of Technology

List of Experiments

Experiment
Title
No.
Introduce the basic concepts and syntax of C++ programming, including
1 I/O operations and variables.
Understanding the structure of C++ programs, the use of operators, and
2 the implementation of assignment statements.

Understand and implement decision-making constructs in C++ using if


3 and if-else statements for controlling the flow of execution based on
conditions.
Explore and apply arithmetic, relational, logical, bit-wise, and assignment
4 operators in C++ for data manipulation and operations
To understand and apply logical operators in C++ for evaluating logical
5 equivalences and controlling program flow.
To implement a 1D array in C++ for representing sets and managing set
6 Element.
To implement set operations in C++ for performing various set-related
7 tasks and manipulations.

To implement and manipulate matrices in C++ through the use of a 2D


8 array.

To apply and analyze various sorting algorithms in C++ for optimizing


9 data organization.

To explore and implement different searching algorithms in C++ for


10 effective data retrieval.
An introduction to the role of functions in C++ programming, with a
11 focus on their application within discrete structures and algorithm design.
To explore recursive functions in C++ and understand their role in
12 handling sequences and discrete structures in algorithmic problem-
Solving.
Open Ended Lab
13

Open Ended Lab


14
The University of Lahore Department of Technology

EVALUATION LOG

Student Name: Shahzaib Khan, Moiz Iqbal Registration No.: 70176698, 70173907

Instructor Name: Instructor Signatur:e

Obtained Marks
LAB No. Checked date Checked by
CLO3 CLO4

10

11

12

13

14
Lab No. 1
Introduce the basic concepts and syntax of C++ programming,
including I/O operations and variables
Objective :
In this lab software introduction has been discussed along with basic writing of the
program inside the compiler and its steps.
Tools:
Dev C++
Background Knowledge:
Dev C++ is an Integrated Development Environment (IDE) for C and C++
programming language. With this environment you can edit, build, run, and debug
your program freely. You can write Windows or console-based C/C++ programs
easily.
C++ is a statically typed, free-form, (usually) compiled, multi-paradigm,
intermediate-level general-purpose middle-level programming language. Many of
today’s operating systems, system drivers, browsers and games use C++ as their core
language. This makes C++ and its software like C Fee and DEV C++ an excellent
choice. Since it is an enhanced/extended version of C programming language, C and
C++ are often denoted together as C/C++.
Sample Tasks
Task 1
Write a program to print your name on the output screen
#include <iostream>
/* this program is print your name on the output
screen */
using namespace std;
int main( )
{
cout<<"Imran khan"<<endl;
}
Task 2
Write a program to calculate the sum of any two numbers on the output screen
#include
<iostream>
using namespace std;
int main( )
{
int a,b,sum;
a=2;
b=3;
sum=a+b;
cout<<"Sum ="<<sum<<endl;
}

Task 3
Write a program to multiply any two numbers and print the result on the output
screen
#include
<iostream>
using namespace std;
int main( )
{
int a,b,mul;
a=2;
b=3;
mul=a*b;
cout<<"Multiply
="<<mul<<endl; return 0;
}

Exercise :
Exercise 1:
Write down the syntax for declaration of variable
Solution:

data_type variable_name;

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 2
Write a program which displays your Bio data on the output screen.
Solution:

#include <iostream>
using namespace std;

int main() {
cout << "Name: Ahmad Nadeem" << endl;
cout << "Age: 25" << endl;
cout << "Address: Karachi, Pakistan" << endl;
cout << "Qualification: Bachelor of Science in Computer Science" << endl;
cout << "Hobbies: Reading, Coding, Traveling" << endl;

return 0;
}

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 3
Write a program to add and multiply any three variables a, b, c and print
the result on the output screen
Solution:

#include using namespace std;

int main() { int a, b, c, sum, product;

cout << "Enter three numbers: ";


cin >> a >> b >> c;

sum = a + b + c;
product = a * b * c;

cout << "Sum = " << sum << endl;


cout << "Product = " << product << endl;

return 0;

Marks Obtained Total Marks

Instructor Signatures:
Remarks:

FINAL EVALUTION LAB 01


Student Name:

Registration Number:

Date:

Marks Obtained Total Marks

Instructor Signatures:

Remarks:
The University of Lahore Department of Technology

Laboratory Work Assessment Rubrics


Sr. Performance
Excellent (5) Good (4) Average (3) Fair (2) Poor (1)
No. Indicator
Student knows very
Student knows all Student knows most
Student knows few of little about the Student has poor
the related of the related
the related concepts related concepts understanding of the
concepts about the concepts about the
about the theoretical about the related concepts about
theoretical theoretical
Theoretical background of the theoretical the theoretical
background of the background of the
1 knowledge experiment and background of the background of the
experiment and experiment and
10% partially rephrase experiment and experiment and unable
rephrase those partially rephrase
those concepts in poorly rephrase to rephrase those
concepts in written those concepts in
written and oral those concepts in concepts in written
and oral written and oral
assessments written and oral and oral assessments
assessments assessments
assessments
Application Application Application does
Application compiles with few compiles and not compile or
Application runs
compiles with no or no warnings. runs without compiles but
Application smoothly and
warnings. Robust Consideration crashing. Some crashes.
2 Functionality operation of the
operation of the given to unusual attempt at Confusing. Little
10% application runs
application, with conditions with detecting and or no error
efficiently
good recovery. reasonable correcting detection or
recovery errors. correction.
The program works
The program
and produces the The program
works very
The program works correct results and produces correct The program is
Specifications efficiently and
3 and meets some of displays them results but does not producing incorrect
10% meets all of the
the specifications. correctly. It also display them results.
required
meets most of the correctly.
specifications.
other specifications.
Provide complete Provide complete Provide partially
Level of and logical and logical answers correct and logical Provide very few
understanding answers based based upon accurate answers based upon and illogical Provide no answer to

4 of the learned upon accurate technical content to minimum technical answers to the the questions asked by
skill technical content the questions asked content to the questions asked by examiner.

10% to the questions by examiner with questions asked by examiner.


asked by examiner few errors examiner
The code is fairly
The code is Some parts of the The code is poorly
Readability easy to read. The
exceptionally well Most of the code code require organized and very
and code could be reused
5 organized and could be reused in change before they difficult to read and
Reusability as a whole or each
very easy to other programs. could be reused in not organized for
10% class could be
follow and reused other programs. reusability.
reused.
The University of Lahore Department of Technology

Some attempt at
Little attempt at
Well-designed Good data layering data. Some Very poor attempt and
layering data.
Object classes with good abstraction and some generalization of missing code. Code is
Missing, duplicate
Oriented data abstraction data layering. Good interface evident but maintenance
6 or not useful class
Design and layering. Code set of operations missed opportunity. headache. No OOP
interface. Some
10% is highly provided. Little Code can be language feature is
OOP language
maintainable duplications maintained with used
feature is used
significant effort
1. Responds well,
quick and very
1. Generally
accurate all the 1. Not much
Responsive and 1. Generally 1. Non-Responsive
time. Responsive and
accurate most of the Responsive and and inaccurate all the
Responsiveness 2. Effectively uses accurate most of
times. accurate few times. times.
to Questions/ eye contact, the times.
7 2. Maintains eye 2. Some eye contact, 2. No eye contact and
Accuracy speaks clearly, 2. Uses eye contact
contact, speaks speaks clearly and unable to speak
10% effectively and ineffectively and
clearly with suitable unclearly in different 3. Dresses
confidently using fails to speak
volume and pace. portions. inappropriately
suitable volume clearly and audibly
and pace.

Some part of the code


The code is The code is fairly
is efficient and other
extremely efficient efficient without The code is brute The code is huge and
Efficiency part of the code is not
8 without sacrificing sacrificing force and appears to be patched
10% understandable and
readability and readability and unnecessarily long together
work properly
understanding understanding

The code was


The program was The program was The program was The code was
Delivery delivered within a
9 delivered in time delivered in Lab delivered within the delivered more than 2
10% day after the due
during lab. before the end time. due date. days overdue.
date.
Student has
Student has Student has little Student has little
sufficient Student has no
sufficient knowledge knowledge of the knowledge of the
Awareness of knowledge of the knowledge of the
of the laboratory laboratory safety laboratory safety
Safety laboratory safety laboratory safety
10 safety SOPs and SOPs and protocol SOPs and protocol
Guidelines SOPs and protocol SOPs and protocol
protocol and is and is Partially and is non-
10% and is fully and is non-compliant
Partially compliant compliant to the compliant to the
compliant to the to the guidelines
to the guidelines guidelines guidelines
guidelines
Lab No. 2
Understanding the structure of C++ programs, the use of operators,
and the implementation of assignment statements
Objective :
In this lab we will
• Learn about data types which are used to define any variable
• Learn about operators and learn how to combine different types of arithmetic opera
tors to form arithmetic expressions.
Tools:
Dev C++
Background Knowledge:
This lab is about the basic C programming structure included cin, cout and endl
operators. We will also learn the data types included integer, floating point, character
and string. In this practice we will implement these data types using different
examples. Together with data types you will also deal with mathematical operators
such as +,*
Assignment Statement
This statement is used to assign a value to a variable is called assignment statement
The assignment statement evaluates an expression and then assigns its value to a
variable. The assignment operator is “=” is used to assign the calculated value to a
variable.
Syntax:
var=expression ;
Where,
var àvariable name to which the value of expression is assigned
expressionàan expression may be a combination of operands and arithmetic operators
.
Sample Tasks
Task 1
Write a program to input length and width in any two variable.

#include<iostream>
using namespace std;
int main ( )
{
int length, width;
cin >> length;
cin >> width;

}
Task 2
Write a program to input length and width in any two variable and print the
result on the output screen

#include<iostream>
using namespace std
int main ( )
{
cout << "Enter the length: "<<endl;
cin >> length;
cout << "Enter the width: "<<endl;
cin >> width;

Task 3
Write a program to assign two variables by assignment statement. Assign the
values and print the result on the screen
#include<iostream>
using namespace std;
Int main ( )
{
int a,b;
a=200;
b=100;
cout<<< “value of a=”<<a<<endl;
cout<< “value of b =”<<b<<endl;

Task4
Write a program to print a message on screen by using “endl” manipulator.

Int main()
{
cout<<"i am a "<<endl<<" pakistani";
}

Task5
Write a program in C++ to get two numbers from keyboard during program
execution. Calculate the sum and product of the numbers and then print the
result on the computer screen.
#include<iostream>
Int main()
{
int n1,n2,s,p;
cout<<"Enter first number ?";
cin>>n1;
cout<<"Enter secound number ?";
cin>>n2;
s=n1+n2;
p=n1*n2;
cout<<"sums of numbers="<<s<<endl;
cout<<"products of numbers="<<p<<endl;
}
Exercise :
Exercise 1:
Write a program to print your name and registration number on the output screen
Solution:
#include <iostream>
using namespace std;

int main() {
cout << "Name: Ahmad Nadeem" << endl;
cout << "Registration Number: 12345-CS-2025" << endl;

return 0;
}

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 2
Write a program to print the menu as below:
This is my first program
My name is Ali
I am electrical engineer want to serve mankind
Solution:

#include <iostream>
using namespace std;

int main() {
cout << "This is my first program" << endl;
cout << "My name is Ali" << endl;
cout << "I am electrical engineer want to serve mankind" << endl;

return 0;
}

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 3
Write a program in C++ to input three values from user at run time and print the
summation and multiplication of these three values on the output screen
Solution:

Write your code here #include using namespace std;

int main() { int a, b, c; int sum, product;

cout << "Enter first number: ";


cin >> a;

cout << "Enter second number: ";


cin >> b;

cout << "Enter third number: ";


cin >> c;
sum = a + b + c;
product = a * b * c;

cout << "Sum of the three numbers = " << sum << endl;
cout << "Product of the three numbers = " << product << endl;

return 0;

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 4:
Write a program in c to input the marks of any three subjects from user at run time
and calculate the total and average marks. Also show the result on the output screen.
Solution:

#include <stdio.h>

int main() {
float subject1, subject2, subject3;
float total, average;

printf("Enter marks of subject 1: ");


scanf("%f", &subject1);

printf("Enter marks of subject 2: ");


scanf("%f", &subject2);

printf("Enter marks of subject 3: ");


scanf("%f", &subject3);

total = subject1 + subject2 + subject3;


average = total / 3;

printf("Total Marks = %.2f\n", total);


printf("Average Marks = %.2f\n", average);

return 0;
}

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 5:
Write a program to get name and age (in years) of a person. Calculate the age in
months and print the name of person and its age in months.
Solution:

#include <iostream>
using namespace std;

int main() {
string name;
int ageInYears;
int ageInMonths;
cout << "Enter your name: ";
getline(cin, name);

cout << "Enter your age in years: ";


cin >> ageInYears;

ageInMonths = ageInYears * 12;

cout << "Name: " << name << endl;


cout << "Age in months: " << ageInMonths << endl;

return 0;
}

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

FINAL EVALUTION LAB 01


Student Name:

Registration Number:

Date:

Marks Obtained Total Marks

Instructor Signatures:
Remarks:

Lab No. 1
Introduction to C++ programming

Objective :
In this lab software introduction has been discussed along with basic writing of the
program inside the compiler and its steps.
Tools:
Dev C++
Background Knowledge:
Dev C++ is an Integrated Development Environment (IDE) for C and C++
programming language. With this environment you can edit, build, run, and debug
your program freely. You can write Windows or console-based C/C++ programs
easily.
C++ is a statically typed, free-form, (usually) compiled, multi-paradigm,
intermediate-level general-purpose middle-level programming language. Many of
today’s operating systems, system drivers, browsers and games use C++ as their core
language. This makes C++ and its software like C Fee and DEV C++ an excellent
choice. Since it is an enhanced/extended version of C programming language, C and
C++ are often denoted together as C/C++.
Sample Tasks
Task 1
Write a program to print your name on the output screen
#include <iostream>
/* this program is print your name on the output
screen */
using namespace std;
int main( )
{
cout<<"Imran khan"<<endl;
}

Task 2
Write a program to calculate the sum of any two numbers on the output screen
#include
<iostream>
using namespace std;
int main( )
{
int a,b,sum;
a=2;
b=3;
sum=a+b;
cout<<"Sum ="<<sum<<endl;
}

Task 3
Write a program to multiply any two numbers and print the result on the output
screen
#include
<iostream>
using namespace std;
int main( )
{
int a,b,mul;
a=2;
b=3;
mul=a*b;
cout<<"Multiply
="<<mul<<endl; return 0;
}

Exercise :
Exercise 1:
Write down the syntax for declaration of variable
Solution:

data_type variable_name;

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 2
Write a proggram which displays your Bio data on the output screen.
Solution:

#include <iostream>
using namespace std;

int main() {
cout << "Name: Ahmad Nadeem" << endl;
cout << "Age: 25" << endl;
cout << "Address: Karachi, Pakistan" << endl;
cout << "Qualification: Bachelor of Science in Computer Science" << endl;
cout << "Hobbies: Reading, Coding, Traveling" << endl;

return 0;
}

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 3
Write a program to add and multiply any three variables a, b, c and print
the result on the output screen
Solution:

#include using namespace std;

int main() { int a, b, c; int sum, product;

cout << "Enter value for a: ";


cin >> a;

cout << "Enter value for b: ";


cin >> b;

cout << "Enter value for c: ";


cin >> c;

sum = a + b + c;
product = a * b * c;

cout << "Sum = " << sum << endl;


cout << "Product = " << product << endl;

return 0;

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

FINAL EVALUTION LAB 01


Student Name:

Registration Number:

Date:

Marks Obtained Total Marks

Instructor Signatures:

Remarks:
The University of Lahore Department of Technology

Laboratory Work Assessment Rubrics


Sr. Performance
Excellent (5) Good (4) Average (3) Fair (2) Poor (1)
No. Indicator
Student knows very
Student knows all Student knows most
Student knows few of little about the Student has poor
the related of the related
the related concepts related concepts understanding of the
concepts about the concepts about the
about the theoretical about the related concepts about
theoretical theoretical
Theoretical background of the theoretical the theoretical
background of the background of the
1 knowledge experiment and background of the background of the
experiment and experiment and
10% partially rephrase experiment and experiment and unable
rephrase those partially rephrase
those concepts in poorly rephrase to rephrase those
concepts in written those concepts in
written and oral those concepts in concepts in written
and oral written and oral
assessments written and oral and oral assessments
assessments assessments
assessments
Application Application Application does
Application compiles with few compiles and not compile or
Application runs
compiles with no or no warnings. runs without compiles but
Application smoothly and
warnings. Robust Consideration crashing. Some crashes.
2 Functionality operation of the
operation of the given to unusual attempt at Confusing. Little
10% application runs
application, with conditions with detecting and or no error
efficiently
good recovery. reasonable correcting detection or
recovery errors. correction.
The program works
The program
and produces the The program
works very
The program works correct results and produces correct The program is
Specifications efficiently and
3 and meets some of displays them results but does not producing incorrect
10% meets all of the
the specifications. correctly. It also display them results.
required
meets most of the correctly.
specifications.
other specifications.
Provide complete Provide complete Provide partially
Level of and logical and logical answers correct and logical Provide very few
understanding answers based based upon accurate answers based upon and illogical Provide no answer to

4 of the learned upon accurate technical content to minimum technical answers to the the questions asked by
skill technical content the questions asked content to the questions asked by examiner.

10% to the questions by examiner with questions asked by examiner.


asked by examiner few errors examiner
The code is fairly
The code is Some parts of the The code is poorly
Readability easy to read. The
exceptionally well Most of the code code require organized and very
and code could be reused
5 organized and could be reused in change before they difficult to read and
Reusability as a whole or each
very easy to other programs. could be reused in not organized for
10% class could be
follow and reused other programs. reusability.
reused.
The University of Lahore Department of Technology

Some attempt at
Little attempt at
Well-designed Good data layering data. Some Very poor attempt and
layering data.
Object classes with good abstraction and some generalization of missing code. Code is
Missing, duplicate
Oriented data abstraction data layering. Good interface evident but maintenance
6 or not useful class
Design and layering. Code set of operations missed opportunity. headache. No OOP
interface. Some
10% is highly provided. Little Code can be language feature is
OOP language
maintainable duplications maintained with used
feature is used
significant effort
1. Responds well,
quick and very
1. Generally
accurate all the 1. Not much
Responsive and 1. Generally 1. Non-Responsive
time. Responsive and
accurate most of the Responsive and and inaccurate all the
Responsiveness 2. Effectively uses accurate most of
times. accurate few times. times.
to Questions/ eye contact, the times.
7 2. Maintains eye 2. Some eye contact, 2. No eye contact and
Accuracy speaks clearly, 2. Uses eye contact
contact, speaks speaks clearly and unable to speak
10% effectively and ineffectively and
clearly with suitable unclearly in different 3. Dresses
confidently using fails to speak
volume and pace. portions. inappropriately
suitable volume clearly and audibly
and pace.

Some part of the code


The code is The code is fairly
is efficient and other
extremely efficient efficient without The code is brute The code is huge and
Efficiency part of the code is not
8 without sacrificing sacrificing force and appears to be patched
10% understandable and
readability and readability and unnecessarily long together
work properly
understanding understanding

The code was


The program was The program was The program was The code was
Delivery delivered within a
9 delivered in time delivered in Lab delivered within the delivered more than 2
10% day after the due
during lab. before the end time. due date. days overdue.
date.
Student has
Student has Student has little Student has little
sufficient Student has no
sufficient knowledge knowledge of the knowledge of the
Awareness of knowledge of the knowledge of the
of the laboratory laboratory safety laboratory safety
Safety laboratory safety laboratory safety
10 safety SOPs and SOPs and protocol SOPs and protocol
Guidelines SOPs and protocol SOPs and protocol
protocol and is and is Partially and is non-
10% and is fully and is non-compliant
Partially compliant compliant to the compliant to the
compliant to the to the guidelines
to the guidelines guidelines guidelines
guidelines
Lab No. 3
Understand and implement decision-making constructs in C++
using if and if-else statements for controlling the flow of execution
based on conditions
Objective :
In this lab you will learn how to write C++ conditions (logical expressions), and you
will learn one way of controlling which C++ statement is executed next (the if
statement)
Tools:
Dev C++
Background Knowledge:
In the sequence construct each statement is executed in the order in which it occurs in
the program. However, many times our actions are dependent on certain conditions.
For instance, if it is raining outside, then you will take an umbrella. But if the sun is
shining, you will leave the umbrella at home. Similarly, a program might need to
execute one statement if one condition occurs and execute a different statement if
another condition occurs.
In programming, decision making is used to specify the order in which statements are
executed. Decision making Decision-making structures require that the programmer
specifies one or more conditions to be evaluated or tested by the program, along with
a statement or statements to be executed if the condition is determined to be true, and
optionally, other statements to be executed if the condition is determined to be false.

if Statement
If statement consists of a Boolean expression followed by one or more statements.
Syntax
The syntax of an ‘if’ statement in C programming language is:
if(boolean_expression)
{
/* statement(s) will execute if the boolean expression is true */
}
If-else Statement
The flow diagram as shown in figure 3.2

Syntax
if(boolean_expression)
{
/* statement(s) will execute if the boolean expression is true */
}
else
{
/* statement(s) will execute if the boolean expression is false */
}
Sample Tasks
Task 1
Write a program to assign value in any variable and check whether it is less than
20 or not
#include <iostream>
Using namespace std;
int main ()
{
int a = 10;
if( a < 20 )
{ cout<<"a is less than 20"<<endl; }
cout<<"value of a is :”<<a;}

Task 2
Write a program to assign value in to variable ‘a’ and check whether it is less
than 20 or not using if else statement
#include<iostream>
Using namespace std;
int main ()
{
int a = 100;
if( a < 20 )
{
cout<< “a is less than 20"<<endl;
}
else
{ cout<<"a is not less than 20"<<endl; }
cout<<"value of a is :"<<a<<endl;
}

Task 3
Write a program to read three integer numbers then find and print the largest
one among these numbers.
#include <iostream>
using namespace std;
int main( )
{
int x,y,z, max;
cin>>x;
cin>>y;
cin>>z;
max=x;
if(max<y)
max=y;
if(max<z)
max=z;
cout<<” The Max Value is:"<<max<<endl; }

Task 4
Write a program to executes a single statement if the given condition is true
#include <iostream>
using namespace std;
main ()
{ int a, b;
a=100;
b=50;
if(a>b)
cout<<“Lahore”<<endl;
cout<<“ok”<<endl; }

Task 5
Write a C++ program to check whether an alphabet is vowel or consonant using
switch case.
#include <iostream>
using namespace std;
int main() {
char ch;
// Ask the user to enter an alphabet
cout << "Enter an alphabet: ";
cin >> ch;
// Convert to lowercase to handle both uppercase and lowercase inputs
ch = tolower(ch);
// Check if the input is a letter
if (ch < 'a' || ch > 'z') {
cout << "Invalid input. Please enter a valid alphabet." << endl;
return 1; // Exit with an error code
}
// Use switch case to check if the character is a vowel or consonant
switch (ch) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
cout << ch << " is a vowel." << endl;
break;
default:
cout << ch << " is a consonant." << endl;
}
}

Exercise :
Exercise 1:
Write a program that determines a student’s grade. The program will read three types
of scores (quiz, mid-term, and final scores) and determine the grade based on the
following rules:
if the average score =90% =>grade=A
if the average score >= 70% and <90% => grade=B
if the average score>=50% and <70% =>grade=C
if the average score<50% =>grade=F
Solution:
Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 2
Write a program that prompts the user for the current year, the user's current age, and
another year. It then calculates the age that the user was or will be in the second year
entered
Solution:
Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 3
Write a program to calculate the electricity bill. The rates of electricity per unit are as
follow If the units consumed are equal or less than 300, then the cost is Rs 3/ per unit
If units consumed are more than 300, then the cost is Rs. 3.5/- per unit and a
surcharge of 5% of bill is added.
Solution:
Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 4
Write a C program to create Simple Calculator using switch case.
Solution:
Marks Obtained Total Marks

Instructor Signatures:

Remarks:

FINAL EVALUTION LAB 01

Student Name:

Registration Number:
11-03-2025
Date:

Marks Obtained Total Marks

Instructor Signatures:
Remarks:
The University of Lahore Department of Technology

Laboratory Work Assessment Rubrics


Sr. Performance
Excellent (5) Good (4) Average (3) Fair (2) Poor (1)
No. Indicator
Student knows very
Student knows all Student knows most
Student knows few of little about the Student has poor
the related of the related
the related concepts related concepts understanding of the
concepts about the concepts about the
about the theoretical about the related concepts about
theoretical theoretical
Theoretical background of the theoretical the theoretical
background of the background of the
1 knowledge experiment and background of the background of the
experiment and experiment and
10% partially rephrase experiment and experiment and unable
rephrase those partially rephrase
those concepts in poorly rephrase to rephrase those
concepts in written those concepts in
written and oral those concepts in concepts in written
and oral written and oral
assessments written and oral and oral assessments
assessments assessments
assessments
Application Application Application does
Application compiles with few compiles and not compile or
Application runs
compiles with no or no warnings. runs without compiles but
Application smoothly and
warnings. Robust Consideration crashing. Some crashes.
2 Functionality operation of the
operation of the given to unusual attempt at Confusing. Little
10% application runs
application, with conditions with detecting and or no error
efficiently
good recovery. reasonable correcting detection or
recovery errors. correction.
The program works
The program
and produces the The program
works very
The program works correct results and produces correct The program is
Specifications efficiently and
3 and meets some of displays them results but does not producing incorrect
10% meets all of the
the specifications. correctly. It also display them results.
required
meets most of the correctly.
specifications.
other specifications.
Provide complete Provide complete Provide partially
Level of and logical and logical answers correct and logical Provide very few
understanding answers based based upon accurate answers based upon and illogical Provide no answer to

4 of the learned upon accurate technical content to minimum technical answers to the the questions asked by
skill technical content the questions asked content to the questions asked by examiner.

10% to the questions by examiner with questions asked by examiner.


asked by examiner few errors examiner
The code is fairly
The code is Some parts of the The code is poorly
Readability easy to read. The
exceptionally well Most of the code code require organized and very
and code could be reused
5 organized and could be reused in change before they difficult to read and
Reusability as a whole or each
very easy to other programs. could be reused in not organized for
10% class could be
follow and reused other programs. reusability.
reused.
The University of Lahore Department of Technology

Some attempt at
Little attempt at
Well-designed Good data layering data. Some Very poor attempt and
layering data.
Object classes with good abstraction and some generalization of missing code. Code is
Missing, duplicate
Oriented data abstraction data layering. Good interface evident but maintenance
6 or not useful class
Design and layering. Code set of operations missed opportunity. headache. No OOP
interface. Some
10% is highly provided. Little Code can be language feature is
OOP language
maintainable duplications maintained with used
feature is used
significant effort
1. Responds well,
quick and very
1. Generally
accurate all the 1. Not much
Responsive and 1. Generally 1. Non-Responsive
time. Responsive and
accurate most of the Responsive and and inaccurate all the
Responsiveness 2. Effectively uses accurate most of
times. accurate few times. times.
to Questions/ eye contact, the times.
7 2. Maintains eye 2. Some eye contact, 2. No eye contact and
Accuracy speaks clearly, 2. Uses eye contact
contact, speaks speaks clearly and unable to speak
10% effectively and ineffectively and
clearly with suitable unclearly in different 3. Dresses
confidently using fails to speak
volume and pace. portions. inappropriately
suitable volume clearly and audibly
and pace.

Some part of the code


The code is The code is fairly
is efficient and other
extremely efficient efficient without The code is brute The code is huge and
Efficiency part of the code is not
8 without sacrificing sacrificing force and appears to be patched
10% understandable and
readability and readability and unnecessarily long together
work properly
understanding understanding

The code was


The program was The program was The program was The code was
Delivery delivered within a
9 delivered in time delivered in Lab delivered within the delivered more than 2
10% day after the due
during lab. before the end time. due date. days overdue.
date.
Student has
Student has Student has little Student has little
sufficient Student has no
sufficient knowledge knowledge of the knowledge of the
Awareness of knowledge of the knowledge of the
of the laboratory laboratory safety laboratory safety
Safety laboratory safety laboratory safety
10 safety SOPs and SOPs and protocol SOPs and protocol
Guidelines SOPs and protocol SOPs and protocol
protocol and is and is Partially and is non-
10% and is fully and is non-compliant
Partially compliant compliant to the compliant to the
compliant to the to the guidelines
to the guidelines guidelines guidelines
guidelines
Lab No. 4
Explore and apply arithmetic, relational, logical, bit-wise, and
assignment operators in C++ for data manipulation and operations.
Objective :
C++ programming has various operators to perform tasks including arithmetic,
conditional and bitwise operations. You will learn about various C operators and how
to use them in this experiment.
Tools:
Dev C++
Background Knowledge:
An operator is a symbol that tells the compiler to perform specific mathematical or
logical functions. C language is rich in built-in operators and provides the following
types of operators:
• Arithmetic Operators
• Relational Operators
• Logical Operators
• Bitwise Operators
• Assignment Operators
The following table4.1 shows all the arithmetic operators supported by the C++
language. Assume variable A holds 10 and variable B holds 20

Relational Operators
The following table 4.2 shows all the relational operators supported by C++. Assume
variable A holds 10 and variable B holds 20, then:
Logical Operators
Following table 4.3 shows all the logical operators supported by C+ language.
Assume variable A holds 1 and variable B holds 0, then:

Bitwise Operators
Bitwise operators work on bits and perform bit-by-bit operation. The truth table for &,
|, and ^ is as follows as shown in Table 4.4

Sample Tasks
Task 1
Write a program to convert millimeter in to inches and display the result on the screen
#include<iostream>
using namespace std;
int main ()
{
float mm,inch;
mm=100.26 ;
inch=mm/25.4;
cout<<mm<<<inch<<”inches”;
}

Task 2
Write a program to add two floating point values and display the sum on the screen
#include<iostream>
using namespace std;
int main ()
{
float a,b,s;
a=10.2;
b=5.5;
s=a+b;
cout<<”Sum of “<< a<<”and”<<b<<”is=”<<s;
}

Task 3
Write a program that convert 37 centigrade temperature in to Fahrenheit using the
formula F=9/5 (C +32) and display the temperature in Fahrenheit.
#include<iostream>
using namespace std;
int main ()
{
float f,c;
c=37;
f=9/5 *c + 32;
cout<<c<<”centigrade=”<<f<<”Fahrenheit”; }

Exercise :
Exercise 1:
Write a program to input any two numbers from user and to perform all arithmetic
operators available in C++
Solution:

#include using namespace std;

int main() { int num1, num2;

cout<<"Enter first number: ";


cin >> num1;

cout << "Enter second number: ";


cin >> num2;

cout << "Addition (num1 + num2) = " << (num1 + num2) << endl;
cout << "Subtraction (num1 - num2) = " << (num1 - num2) << endl;
cout << "Multiplication (num1 * num2) = " << (num1 * num2) << endl;
if (num2 != 0) {
cout << "Division (num1 / num2) = " << (num1 / num2) << endl;
cout << "Modulus (num1 % num2) = " << (num1 % num2) << endl;
} else {
cout << "Division and modulus by zero is not allowed." << endl;
}

return 0;

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 2
Write a program to input any two numbers from user and to perform all relational
operators
Solution:

#include <iostream>
using namespace std;

int main() {
int num1, num2;

cout << "Enter first number: ";


cin >> num1;

cout << "Enter second number: ";


cin >> num2;

cout << num1 << " == " << num2 << " : " << (num1 == num2) << endl;
cout << num1 << " != " << num2 << " : " << (num1 != num2) << endl;
cout << num1 << " > " << num2 << " : " << (num1 > num2) << endl;
cout << num1 << " < " << num2 << " : " << (num1 < num2) << endl;
cout << num1 << " >= " << num2 << " : " << (num1 >= num2) << endl;
cout << num1 << " <= " << num2 << " : " << (num1 <= num2) << endl;

return 0;
}

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 3
Write a program to input any two numbers from user and to perform all logical
operators
Solution:

#include <iostream>
using namespace std;

int main() {
bool a, b;

cout << "Enter first boolean value (0 or 1): ";


cin >> a;

cout << "Enter second boolean value (0 or 1): ";


cin >> b;

cout << "a && b = " << (a && b) << endl;


cout << "a || b = " << (a || b) << endl;
cout << "!a = " << (!a) << endl;
cout << "!b = " << (!b) << endl;

return 0;
}

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 4:
Write a program to swap two variables using arithmetic operation without using the
3rd variable
Solution:

#include <iostream>
using namespace std;

int main() {
int a, b;

cout << "Enter value of a: ";


cin >> a;

cout << "Enter value of b: ";


cin >> b;
// Swap using arithmetic operations
a = a + b; // Step 1
b = a - b; // Step 2
a = a - b; // Step 3

cout << "After swapping:" << endl;


cout << "a = " << a << endl;
cout << "b = " << b << endl;

return 0;
}

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

FINAL EVALUTION LAB 04


Student Name:

Registration Number:

Date:

Marks Obtained Total Marks

Instructor Signatures:

Remarks:
The University of Lahore Department of Technology

Laboratory Work Assessment Rubrics


Sr. Performance
Excellent (5) Good (4) Average (3) Fair (2) Poor (1)
No. Indicator
Student knows very
Student knows all Student knows most
Student knows few of little about the Student has poor
the related of the related
the related concepts related concepts understanding of the
concepts about the concepts about the
about the theoretical about the related concepts about
theoretical theoretical
Theoretical background of the theoretical the theoretical
background of the background of the
1 knowledge experiment and background of the background of the
experiment and experiment and
10% partially rephrase experiment and experiment and unable
rephrase those partially rephrase
those concepts in poorly rephrase to rephrase those
concepts in written those concepts in
written and oral those concepts in concepts in written
and oral written and oral
assessments written and oral and oral assessments
assessments assessments
assessments
Application Application Application does
Application compiles with few compiles and not compile or
Application runs
compiles with no or no warnings. runs without compiles but
Application smoothly and
warnings. Robust Consideration crashing. Some crashes.
2 Functionality operation of the
operation of the given to unusual attempt at Confusing. Little
10% application runs
application, with conditions with detecting and or no error
efficiently
good recovery. reasonable correcting detection or
recovery errors. correction.
The program works
The program
and produces the The program
works very
The program works correct results and produces correct The program is
Specifications efficiently and
3 and meets some of displays them results but does not producing incorrect
10% meets all of the
the specifications. correctly. It also display them results.
required
meets most of the correctly.
specifications.
other specifications.
Provide complete Provide complete Provide partially
Level of and logical and logical answers correct and logical Provide very few
understanding answers based based upon accurate answers based upon and illogical Provide no answer to

4 of the learned upon accurate technical content to minimum technical answers to the the questions asked by
skill technical content the questions asked content to the questions asked by examiner.

10% to the questions by examiner with questions asked by examiner.


asked by examiner few errors examiner
The code is fairly
The code is Some parts of the The code is poorly
Readability easy to read. The
exceptionally well Most of the code code require organized and very
and code could be reused
5 organized and could be reused in change before they difficult to read and
Reusability as a whole or each
very easy to other programs. could be reused in not organized for
10% class could be
follow and reused other programs. reusability.
reused.
The University of Lahore Department of Technology

Some attempt at
Little attempt at
Well-designed Good data layering data. Some Very poor attempt and
layering data.
Object classes with good abstraction and some generalization of missing code. Code is
Missing, duplicate
Oriented data abstraction data layering. Good interface evident but maintenance
6 or not useful class
Design and layering. Code set of operations missed opportunity. headache. No OOP
interface. Some
10% is highly provided. Little Code can be language feature is
OOP language
maintainable duplications maintained with used
feature is used
significant effort
1. Responds well,
quick and very
1. Generally
accurate all the 1. Not much
Responsive and 1. Generally 1. Non-Responsive
time. Responsive and
accurate most of the Responsive and and inaccurate all the
Responsiveness 2. Effectively uses accurate most of
times. accurate few times. times.
to Questions/ eye contact, the times.
7 2. Maintains eye 2. Some eye contact, 2. No eye contact and
Accuracy speaks clearly, 2. Uses eye contact
contact, speaks speaks clearly and unable to speak
10% effectively and ineffectively and
clearly with suitable unclearly in different 3. Dresses
confidently using fails to speak
volume and pace. portions. inappropriately
suitable volume clearly and audibly
and pace.

Some part of the code


The code is The code is fairly
is efficient and other
extremely efficient efficient without The code is brute The code is huge and
Efficiency part of the code is not
8 without sacrificing sacrificing force and appears to be patched
10% understandable and
readability and readability and unnecessarily long together
work properly
understanding understanding

The code was


The program was The program was The program was The code was
Delivery delivered within a
9 delivered in time delivered in Lab delivered within the delivered more than 2
10% day after the due
during lab. before the end time. due date. days overdue.
date.
Student has
Student has Student has little Student has little
sufficient Student has no
sufficient knowledge knowledge of the knowledge of the
Awareness of knowledge of the knowledge of the
of the laboratory laboratory safety laboratory safety
Safety laboratory safety laboratory safety
10 safety SOPs and SOPs and protocol SOPs and protocol
Guidelines SOPs and protocol SOPs and protocol
protocol and is and is Partially and is non-
10% and is fully and is non-compliant
Partially compliant compliant to the compliant to the
compliant to the to the guidelines
to the guidelines guidelines guidelines
guidelines
Lab No. 5

To understand and apply logical operators in C++ for evaluating


logical equivalences and controlling program flow

Objective :
This lab aims to help students understand and apply logical operators (&&, ||, !) in
C++ by creating truth tables, testing logical equivalences (like De Morgan’s Laws),
and practicing short-circuit evaluation. Students will implement logical expressions in
code, validate equivalences, and apply these skills to practical programming
scenarios.
Tools:
Dev C++
Background Knowledge:
Compound propositions that have the same truth values in all possible cases are called
logically equivalent. We can also define this notion as follows, “The compound
propositions p and q are called logically equivalent if p ↔ q is a tautology. The
notation p ≡ q denotes that p and q are logically equivalent.”
The following are some important logical equivalences

In today’s lab we will extend our previous lab work and use it to prove different
logical equivalences. The use of AND, OR and Not have been told earlier. This lab
will use few more logical operators which will be used to prove the logical
equivalences.
Example:
TRUE: Has a value 1.
False: Has a value 0.
NOT: used for negation.

Sample Tasks
Task 1
Write a program to proof identity law and display the result on the screen
#include<iostream>
using namespace std;
int main ()
{
int p;
cout<<” Enter a Boolean value for p”;
cin>>p;
cout<<p&True;
}

Task 2
Write a program to proof double negation law and display the rsult on the screen
#include <iostream>
using namespace std;
int main() {
bool A = true; // You can change this to false to test both cases
// Applying double negation
bool result = !( !A );
cout <<"Value of A: "<< A << endl;
cout <<"Double negation of A ( !( !A ) ): "<< result << endl;
if (result == A) {
cout <<"Double negation law holds: !( !A ) is equivalent to A"<< endl;
} else {
cout <<"Double negation law does not hold"<< endl;}}
Task 3
Write a program that veriy the commutative law in C++.
#include <iostream>
using namespace std;
int main() {
bool A = true; // You can change these values to test different cases
bool B = false;
// Applying commutative law for AND (A && B is equivalent to B && A)
bool andResult1 = A && B;
bool andResult2 = B && A;
// Displaying the results
cout <<"A && B: "<< andResult1 << endl;
cout <<"B && A: "<< andResult2 << endl;
cout <<"Commutative law for AND holds: "<< (andResult1 == andResult2) <<
endl;
}

Exercise :
Exercise 1:
Write a program to verify the distributive law by using logical operators available in
C++
Solution:
MarksObtained Total Marks

InstructorSignatures:
Remarks:

Exercise 2
Write a program to verify the Demorgan’s law by using logical operators available in
C++
Solution:

MarksObtained Total Marks

InstructorSignatures:

Remarks:

FINALEVALUTIONLAB 04
StudentName:

RegistrationNumber:

Date:

MarksObtained Total Marks


InstructorSignatures:

Remarks:
The University of Lahore Department of Technology

Laboratory Work Assessment Rubrics


Sr. Performance
Excellent (5) Good (4) Average (3) Fair (2) Poor (1)
No. Indicator
Student knows very
Student knows all Student knows most
Student knows few of little about the Student has poor
the related of the related
the related concepts related concepts understanding of the
concepts about the concepts about the
about the theoretical about the related concepts about
theoretical theoretical
Theoretical background of the theoretical the theoretical
background of the background of the
1 knowledge experiment and background of the background of the
experiment and experiment and
10% partially rephrase experiment and experiment and unable
rephrase those partially rephrase
those concepts in poorly rephrase to rephrase those
concepts in written those concepts in
written and oral those concepts in concepts in written
and oral written and oral
assessments written and oral and oral assessments
assessments assessments
assessments
Application Application Application does
Application compiles with few compiles and not compile or
Application runs
compiles with no or no warnings. runs without compiles but
Application smoothly and
warnings. Robust Consideration crashing. Some crashes.
2 Functionality operation of the
operation of the given to unusual attempt at Confusing. Little
10% application runs
application, with conditions with detecting and or no error
efficiently
good recovery. reasonable correcting detection or
recovery errors. correction.
The program works
The program
and produces the The program
works very
The program works correct results and produces correct The program is
Specifications efficiently and
3 and meets some of displays them results but does not producing incorrect
10% meets all of the
the specifications. correctly. It also display them results.
required
meets most of the correctly.
specifications.
other specifications.
Provide complete Provide complete Provide partially
Level of and logical and logical answers correct and logical Provide very few
understanding answers based based upon accurate answers based upon and illogical Provide no answer to

4 of the learned upon accurate technical content to minimum technical answers to the the questions asked by
skill technical content the questions asked content to the questions asked by examiner.

10% to the questions by examiner with questions asked by examiner.


asked by examiner few errors examiner
The code is fairly
The code is Some parts of the The code is poorly
Readability easy to read. The
exceptionally well Most of the code code require organized and very
and code could be reused
5 organized and could be reused in change before they difficult to read and
Reusability as a whole or each
very easy to other programs. could be reused in not organized for
10% class could be
follow and reused other programs. reusability.
reused.
The University of Lahore Department of Technology

Some attempt at
Little attempt at
Well-designed Good data layering data. Some Very poor attempt and
layering data.
Object classes with good abstraction and some generalization of missing code. Code is
Missing, duplicate
Oriented data abstraction data layering. Good interface evident but maintenance
6 or not useful class
Design and layering. Code set of operations missed opportunity. headache. No OOP
interface. Some
10% is highly provided. Little Code can be language feature is
OOP language
maintainable duplications maintained with used
feature is used
significant effort
1. Responds well,
quick and very
1. Generally
accurate all the 1. Not much
Responsive and 1. Generally 1. Non-Responsive
time. Responsive and
accurate most of the Responsive and and inaccurate all the
Responsiveness 2. Effectively uses accurate most of
times. accurate few times. times.
to Questions/ eye contact, the times.
7 2. Maintains eye 2. Some eye contact, 2. No eye contact and
Accuracy speaks clearly, 2. Uses eye contact
contact, speaks speaks clearly and unable to speak
10% effectively and ineffectively and
clearly with suitable unclearly in different 3. Dresses
confidently using fails to speak
volume and pace. portions. inappropriately
suitable volume clearly and audibly
and pace.

Some part of the code


The code is The code is fairly
is efficient and other
extremely efficient efficient without The code is brute The code is huge and
Efficiency part of the code is not
8 without sacrificing sacrificing force and appears to be patched
10% understandable and
readability and readability and unnecessarily long together
work properly
understanding understanding

The code was


The program was The program was The program was The code was
Delivery delivered within a
9 delivered in time delivered in Lab delivered within the delivered more than 2
10% day after the due
during lab. before the end time. due date. days overdue.
date.
Student has
Student has Student has little Student has little
sufficient Student has no
sufficient knowledge knowledge of the knowledge of the
Awareness of knowledge of the knowledge of the
of the laboratory laboratory safety laboratory safety
Safety laboratory safety laboratory safety
10 safety SOPs and SOPs and protocol SOPs and protocol
Guidelines SOPs and protocol SOPs and protocol
protocol and is and is Partially and is non-
10% and is fully and is non-compliant
Partially compliant compliant to the compliant to the
compliant to the to the guidelines
to the guidelines guidelines guidelines
guidelines
Lab No. 06
To implement a 1D array in C++ for representing sets and managing
set element.
Objective :
The objectives of a C++ sets lab focus on understanding and implementing sets as
unique collections of elements.This lab strengthens your grasp of sets in C++,
focusing on both implementation and problem-solving applications.
Tools:
Dev C++
Background Knowledge:
Set theory is a fundamental branch of mathematics focused on the study of sets, which
are collections of distinct elements or objects. It provides a framework to understand
how to group objects, define relationships between groups, and perform operations on
these groups.
To omplement sets we use arrays in programming.An array is a collection of items
stored at contiguous memory locations. The idea is to store multiple items of the same
type together. This makes it easier to calculate the position of each element by simply
adding an offset to a base value, i.e., the memory location of the first element of the
array (generally denoted by the name of the array). The base value is index 0 and the
difference between the two indexes is the offset.For simplicity, we can think of an
array as a fleet of stairs where on each step is placed a value (let’s say one of your
friends).
Syntax of an array

Sample Tasks
Task 1
Write a program that initialize an array of 5 elements and display each element on the
screen.
#include <iostream>
using namespace std;
int main() {
int arr[5]; // Array of 5 elements
Arr[5]={2,4,6,8,10}
cout << "You entered: ";
for (int i = 0; i < 5; i++) {
cout << arr[i] << " ";
}
cout << endl;}

Task 2
Write a program that declared an array of 5 elements and take input from user and
display each element on the screen.
#include <iostream>
using namespace std;
int main() {
int arr[5]; // Array of 5 elements
cout << "Enter 5 elements: ";
for (int i = 0; i < 5; i++) {
cin >> arr[i];
}
cout << "You entered: ";
for (int i = 0; i < 5; i++) {
cout << arr[i] << " ";
}
cout << endl;
}
Task 3
Write a program that take one sets of first five odd integers and add these numbers
and display the result on screen.
#include <iostream>
using namespace std;
int main() {
odd[5] = {1,3,5,7,9};
sum = 0;
count = 0;

// calculate the sum


sum += n;
// count the no. of array elements
++count;
}
// print the sum
cout << "\nTheir Sum = " << sum << endl;

Exercise :
Exercise 1:
Write a program to reverse an array in C++
Solution:
#include <iostream>
using namespace std;

int main() {
const int SIZE = 10;
int arr[SIZE];
cout << "Enter " << SIZE << " integers:" << endl;
for (int i = 0; i < SIZE; i++) {
cout << "Element " << i + 1 << ": ";
cin >> arr[i];
}
for (int i = 0; i < SIZE / 2; i++) {
int temp = arr[i];
arr[i] = arr[SIZE - 1 - i];
arr[SIZE - 1 - i] = temp;
}
cout << "Reversed array:" << endl;
for (int i = 0; i < SIZE; i++) {
cout << arr[i] << " ";
}
cout << endl;

return 0;
}

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 2
Write a program to find out number of even and odd out of array of size 10.
Solution:

#include <iostream>
using namespace std;

int main() {
int numbers[10];
int evenCount = 0, oddCount = 0;
cout << "Enter 10 integers:" << endl;
for (int i = 0; i < 10; i++) {
cout << "Enter number " << i + 1 << ": ";
cin >> numbers[i];
if (numbers[i] % 2 == 0) {
evenCount++;
} else {
oddCount++;
}
}
cout << "Number of even numbers: " << evenCount << endl;
cout << "Number of odd numbers: " << oddCount << endl;

return 0;
}

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

FINAL EVALUTION LAB 06


Student Name:
Registration Number:

Date:

Marks Obtained Total Marks

Instructor Signatures:

Remarks:
The University of Lahore Department of Technology

Laboratory Work Assessment Rubrics


Sr. Performance
Excellent (5) Good (4) Average (3) Fair (2) Poor (1)
No. Indicator
Student knows very
Student knows all Student knows most
Student knows few of little about the Student has poor
the related of the related
the related concepts related concepts understanding of the
concepts about the concepts about the
about the theoretical about the related concepts about
theoretical theoretical
Theoretical background of the theoretical the theoretical
background of the background of the
1 knowledge experiment and background of the background of the
experiment and experiment and
10% partially rephrase experiment and experiment and unable
rephrase those partially rephrase
those concepts in poorly rephrase to rephrase those
concepts in written those concepts in
written and oral those concepts in concepts in written
and oral written and oral
assessments written and oral and oral assessments
assessments assessments
assessments
Application Application Application does
Application compiles with few compiles and not compile or
Application runs
compiles with no or no warnings. runs without compiles but
Application smoothly and
warnings. Robust Consideration crashing. Some crashes.
2 Functionality operation of the
operation of the given to unusual attempt at Confusing. Little
10% application runs
application, with conditions with detecting and or no error
efficiently
good recovery. reasonable correcting detection or
recovery errors. correction.
The program works
The program
and produces the The program
works very
The program works correct results and produces correct The program is
Specifications efficiently and
3 and meets some of displays them results but does not producing incorrect
10% meets all of the
the specifications. correctly. It also display them results.
required
meets most of the correctly.
specifications.
other specifications.
Provide complete Provide complete Provide partially
Level of and logical and logical answers correct and logical Provide very few
understanding answers based based upon accurate answers based upon and illogical Provide no answer to

4 of the learned upon accurate technical content to minimum technical answers to the the questions asked by
skill technical content the questions asked content to the questions asked by examiner.

10% to the questions by examiner with questions asked by examiner.


asked by examiner few errors examiner
The code is fairly
The code is Some parts of the The code is poorly
Readability easy to read. The
exceptionally well Most of the code code require organized and very
and code could be reused
5 organized and could be reused in change before they difficult to read and
Reusability as a whole or each
very easy to other programs. could be reused in not organized for
10% class could be
follow and reused other programs. reusability.
reused.
The University of Lahore Department of Technology

Some attempt at
Little attempt at
Well-designed Good data layering data. Some Very poor attempt and
layering data.
Object classes with good abstraction and some generalization of missing code. Code is
Missing, duplicate
Oriented data abstraction data layering. Good interface evident but maintenance
6 or not useful class
Design and layering. Code set of operations missed opportunity. headache. No OOP
interface. Some
10% is highly provided. Little Code can be language feature is
OOP language
maintainable duplications maintained with used
feature is used
significant effort
1. Responds well,
quick and very
1. Generally
accurate all the 1. Not much
Responsive and 1. Generally 1. Non-Responsive
time. Responsive and
accurate most of the Responsive and and inaccurate all the
Responsiveness 2. Effectively uses accurate most of
times. accurate few times. times.
to Questions/ eye contact, the times.
7 2. Maintains eye 2. Some eye contact, 2. No eye contact and
Accuracy speaks clearly, 2. Uses eye contact
contact, speaks speaks clearly and unable to speak
10% effectively and ineffectively and
clearly with suitable unclearly in different 3. Dresses
confidently using fails to speak
volume and pace. portions. inappropriately
suitable volume clearly and audibly
and pace.

Some part of the code


The code is The code is fairly
is efficient and other
extremely efficient efficient without The code is brute The code is huge and
Efficiency part of the code is not
8 without sacrificing sacrificing force and appears to be patched
10% understandable and
readability and readability and unnecessarily long together
work properly
understanding understanding

The code was


The program was The program was The program was The code was
Delivery delivered within a
9 delivered in time delivered in Lab delivered within the delivered more than 2
10% day after the due
during lab. before the end time. due date. days overdue.
date.
Student has
Student has Student has little Student has little
sufficient Student has no
sufficient knowledge knowledge of the knowledge of the
Awareness of knowledge of the knowledge of the
of the laboratory laboratory safety laboratory safety
Safety laboratory safety laboratory safety
10 safety SOPs and SOPs and protocol SOPs and protocol
Guidelines SOPs and protocol SOPs and protocol
protocol and is and is Partially and is non-
10% and is fully and is non-compliant
Partially compliant compliant to the compliant to the
compliant to the to the guidelines
to the guidelines guidelines guidelines
guidelines
Lab No. 7
To implement set operations in C++ for performing various set-
related tasks and manipulations.

Objective :
In this lab we understand the working of bubble sort and selection sort and
implementation of these algorithms in C++.
Tools:
Dev C++
Background Knowledge:
Sorting algorithms are techniques used to arrange elements in a list or array in a
particular order (e.g., ascending or descending). They are fundamental in computer
science and come in various types, each with different performance characteristics
and use cases.
Bubble Sort is a simple sorting algorithm that repeatedly steps through the list,
compares adjacent elements, and swaps them if they are in the wrong order. The pass
through the list is repeated until the list is sorted.
Selection Sort is a sorting algorithm that divides the input list into two parts: the
sorted part and the unsorted part. It repeatedly selects the smallest (or largest) element
from the unsorted part and moves it to the sorted part.
Sample Tasks
Task 1
Write an algorithm of bubble sorting.

1. Start from the first element of the array.


2. Compare the current element with the next element
3. If the current element is greater than the next, swap them.
4. Repeat steps 2 and 3 for all elements.
5. Repeat the entire process for n-1 passes.

Solution:

1. Start
2. Input the array and its size n
3. Repeat for i from 0 to n - 2
a. Repeat for j from 0 to n - i - 2
b. If array[j] > array[j + 1]
Swap array[j] and array[j + 1]
4. End Repeat (inner loop)
5. End Repeat (outer loop)
6. Display the sorted array
7. Stop

Task 2
Write an algorithm for selection sorting.

1) Start from the first element of the array.


2) Find the smallest element in the unsorted part of the array.
3) Swap it with the first element of the unsorted part.
4) Move the boundary of the sorted part one step forward.
5) Repeat until the entire array is sorted.

Solution:

1. Start
2. Input the array and its size n
3. Repeat for i from 0 to n - 2
a. Set minIndex = i
b. Repeat for j from i + 1 to n - 1
If array[j] < array[minIndex]
Set minIndex = j
c. If minIndex != i
Swap array[i] and array[minIndex]
4. End Repeat
5. Display the sorted array
6. Stop

Exercise :
Exercise 1:
Write down the code for bubble sorting in C++.
Solution:
#include <iostream>
using namespace std;

void bubbleSort(int arr[], int n) {


for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (arr[j] > arr[j + 1]) {
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}

void printArray(int arr[], int n) {


for (int i = 0; i < n; i++)
cout << arr[i] << " ";
cout << endl;
}

int main() {
int arr[] = {64, 34, 25, 12, 22, 11, 90};
int n = size
Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 2
Write a program which display the array after sorting by using selection
algorithm in c++.
Solution:
#include <iostream>
using namespace std;

void selectionSort(int arr[], int n) {


for (int i = 0; i < n - 1; i++) {
int minIndex = i;

for (int j = i + 1; j < n; j++) {


if (arr[j] < arr[minIndex]) {
minIndex = j;
}
}

if (minIndex != i) {
int temp = arr[i];
arr[i] = arr[minIndex];
arr[minIndex] = temp;
}
}
}

void printArray(int arr[], int n) {


for (int i = 0; i < n; i++)
cout << arr[i] << " ";
cout << endl;
}

int main() {
int arr[] = {29, 10, 14, 37, 13};
int n = sizeof(arr) / sizeof(arr[0]);

cout << "Original array: ";


printArray(arr, n);

selectionSort(arr, n);

cout << "Sorted array: ";


printArray(arr, n);
return 0;
}

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

FINAL EVALUTION LAB 07


Student Name:

Registration Number:

Date:

Marks Obtained Total Marks

Instructor Signatures:

Remarks:
The University of Lahore Department of Technology

Laboratory Work Assessment Rubrics


Sr. Performance
Excellent (5) Good (4) Average (3) Fair (2) Poor (1)
No. Indicator
Student knows very
Student knows all Student knows most
Student knows few of little about the Student has poor
the related of the related
the related concepts related concepts understanding of the
concepts about the concepts about the
about the theoretical about the related concepts about
theoretical theoretical
Theoretical background of the theoretical the theoretical
background of the background of the
1 knowledge experiment and background of the background of the
experiment and experiment and
10% partially rephrase experiment and experiment and unable
rephrase those partially rephrase
those concepts in poorly rephrase to rephrase those
concepts in written those concepts in
written and oral those concepts in concepts in written
and oral written and oral
assessments written and oral and oral assessments
assessments assessments
assessments
Application Application Application does
Application compiles with few compiles and not compile or
Application runs
compiles with no or no warnings. runs without compiles but
Application smoothly and
warnings. Robust Consideration crashing. Some crashes.
2 Functionality operation of the
operation of the given to unusual attempt at Confusing. Little
10% application runs
application, with conditions with detecting and or no error
efficiently
good recovery. reasonable correcting detection or
recovery errors. correction.
The program works
The program
and produces the The program
works very
The program works correct results and produces correct The program is
Specifications efficiently and
3 and meets some of displays them results but does not producing incorrect
10% meets all of the
the specifications. correctly. It also display them results.
required
meets most of the correctly.
specifications.
other specifications.
Provide complete Provide complete Provide partially
Level of and logical and logical answers correct and logical Provide very few
understanding answers based based upon accurate answers based upon and illogical Provide no answer to

4 of the learned upon accurate technical content to minimum technical answers to the the questions asked by
skill technical content the questions asked content to the questions asked by examiner.

10% to the questions by examiner with questions asked by examiner.


asked by examiner few errors examiner
The code is fairly
The code is Some parts of the The code is poorly
Readability easy to read. The
exceptionally well Most of the code code require organized and very
and code could be reused
5 organized and could be reused in change before they difficult to read and
Reusability as a whole or each
very easy to other programs. could be reused in not organized for
10% class could be
follow and reused other programs. reusability.
reused.
The University of Lahore Department of Technology

Some attempt at
Little attempt at
Well-designed Good data layering data. Some Very poor attempt and
layering data.
Object classes with good abstraction and some generalization of missing code. Code is
Missing, duplicate
Oriented data abstraction data layering. Good interface evident but maintenance
6 or not useful class
Design and layering. Code set of operations missed opportunity. headache. No OOP
interface. Some
10% is highly provided. Little Code can be language feature is
OOP language
maintainable duplications maintained with used
feature is used
significant effort
1. Responds well,
quick and very
1. Generally
accurate all the 1. Not much
Responsive and 1. Generally 1. Non-Responsive
time. Responsive and
accurate most of the Responsive and and inaccurate all the
Responsiveness 2. Effectively uses accurate most of
times. accurate few times. times.
to Questions/ eye contact, the times.
7 2. Maintains eye 2. Some eye contact, 2. No eye contact and
Accuracy speaks clearly, 2. Uses eye contact
contact, speaks speaks clearly and unable to speak
10% effectively and ineffectively and
clearly with suitable unclearly in different 3. Dresses
confidently using fails to speak
volume and pace. portions. inappropriately
suitable volume clearly and audibly
and pace.

Some part of the code


The code is The code is fairly
is efficient and other
extremely efficient efficient without The code is brute The code is huge and
Efficiency part of the code is not
8 without sacrificing sacrificing force and appears to be patched
10% understandable and
readability and readability and unnecessarily long together
work properly
understanding understanding

The code was


The program was The program was The program was The code was
Delivery delivered within a
9 delivered in time delivered in Lab delivered within the delivered more than 2
10% day after the due
during lab. before the end time. due date. days overdue.
date.
Student has
Student has Student has little Student has little
sufficient Student has no
sufficient knowledge knowledge of the knowledge of the
Awareness of knowledge of the knowledge of the
of the laboratory laboratory safety laboratory safety
Safety laboratory safety laboratory safety
10 safety SOPs and SOPs and protocol SOPs and protocol
Guidelines SOPs and protocol SOPs and protocol
protocol and is and is Partially and is non-
10% and is fully and is non-compliant
Partially compliant compliant to the compliant to the
compliant to the to the guidelines
to the guidelines guidelines guidelines
guidelines
Lab No. 8
To implement and manipulate matrices in C++ through the use of a
2D array
Objective :
In a C++ matrices lab, students typically aim to achieve several key learning
objectives. These objectives focus on both understanding the theoretical concepts of
matrices and gaining practical programming skills to manipulate matrices.
Tools:
Dev C++
Background Knowledge:
A matrix can be described as a rectangular array of numbers. A matrix that has m
numbers of rows and n number of columns, then it will be known as an mxn
matrix.Matrices are very useful objects with many applications. Loosely speaking,
they are a two-dimensional array .
A 2D array is a collection of elements arranged in rows and columns. It is indexed by
two indices: one for the row and another for the column. Each element in a 2D array
is accessed using two indices. For example, array[i][j] refers to the element at row i
and column j.2D array is represented as a contiguous block of memory, with elements
arranged row by row or column by column. In languages like C, C++, and Java, a 2D
array is typically implemented as an array of arrays. Each "row" is itself an array of
elements.
Initialization
ou can initialize a 2D array during declaration or later in the program. During
declaration, you specify the dimensions and provide initial values for each element.
For example:
int array[3][3] = { {1, 2, 3},
{4, 5, 6},
{7, 8, 9} };
Sample Tasks
Task 1
Write a program to print 2-D array on the output screen
#include <iostream>
using namespace std;
int main() {
// Define a 2D array
const int rows = 3;
const int cols = 4;
int array[rows][cols] = {
{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12}
};
// Print the 2D array
cout << "The 2D array is: " << endl;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
cout << array[i][j] << " ";
}
cout << endl; // Move to the next row
}
}

Task 2
Write a program that take input frm the user and print the 2D array on the
output screen.
#include <iostream>
using namespace std;
int main() {
// Define the dimensions of the 2D array
int rows, cols;
cout << "Enter the number of rows: ";
cin >> rows;
cout << "Enter the number of columns: ";
cin >> cols;
int array[rows][cols];
// Input elements of the 2D array
cout << "Enter the elements of the 2D array:" << endl;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
cout << "Element at [" << i << "][" << j << "]: ";
cin >> array[i][j];}}

// Print the 2D array


cout << "\nThe 2D array is:" << endl;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
cout << array[i][j] << " ";
}
cout << endl; // Move to the next row
}
}

Task 3
Write a program for addition of two 2-D arrays in C++.
#include <iostream>
using namespace std;

void addMatrices(int rows, int cols, int A[][10], int B[][10], int C[][10]) {
for(int i = 0; i < rows; ++i)
for(int j = 0; j < cols; ++j)
C[i][j] = A[i][j] + B[i][j];
}

int main() {
int A[10][10] = { {1, 2}, {3, 4} };
zz int B[10][10] = { {5, 6}, {7, 8} };
int C[10][10];
int rows = 2, cols = 2;

addMatrices(rows, cols, A, B, C);


cout << "Resultant Matrix: " << endl;
for(int i = 0; i < rows; ++i) {
for(int j = 0; j < cols; ++j)
cout << C[i][j] << " ";
cout << endl;
}
}

Exercise :
Exercise 1:
Write a program to compute and display the sum of each row and each column in a
2D array.
Solution:

#include <iostream>
using namespace std;

int main() {
const int rows = 3;
const int cols = 4;
int arr[rows][cols] = {
{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12}
};

cout << "Sum of each row:" << endl;


for (int i = 0; i < rows; i++) {
int rowSum = 0;
for (int j = 0; j < cols; j++) {
rowSum += arr[i][j];
}
cout << "Row " << i + 1 << ": " << rowSum << endl;
}

cout << "\nSum of each column:" << endl;


for (int j = 0; j < cols; j++) {
int colSum = 0;
for (int i = 0; i < rows; i++) {
colSum += arr[i][j];
}
cout << "Column " << j + 1 << ": " << colSum << endl;
}

return 0;
}

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 2
Write a program to find the maximum element in a 2D array.
Solution:

#include <iostream>
using namespace std;

int main() {
const int rows = 3;
const int cols = 4;
int arr[rows][cols] = {
{7, 2, 9, 4},
{5, 16, 1, 8},
{3, 10, 6, 12}
};

int maxElement = arr[0][0];

for (int i = 0; i < rows; i++) {


for (int j = 0; j < cols; j++) {
if (arr[i][j] > maxElement) {
maxElement = arr[i][j];
}
}
}

cout << "The maximum element in the 2D array is: " << maxElement << endl;

return 0;
}

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 3
Write a program to add two matrices of the same size.
Solution:

#include <iostream>
using namespace std;
int main() {
const int rows = 3;
const int cols = 3;

int matrix1[rows][cols] = {
{1, 2, 3},
{4, 5, 6},
{7, 8, 9}
};

int matrix2[rows][cols] = {
{9, 8, 7},
{6, 5, 4},
{3, 2, 1}
};

int sum[rows][cols];

for (int i = 0; i < rows; i++) {


for (int j = 0; j < cols; j++) {
sum[i][j] = matrix1[i][j] + matrix2[i][j];
}
}

cout << "Sum of the two matrices:" << endl;


for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
cout << sum[i][j] << " ";
}
cout << endl;
}

return 0;
}
Marks Obtained Total Marks

Instructor Signatures:

Remarks:

FINAL EVALUTION LAB 08


Student Name:

Registration Number:

Date:

Marks Obtained Total Marks

Instructor Signatures:

Remarks:
The University of Lahore Department of Technology

Laboratory Work Assessment Rubrics


Sr. Performance
Excellent (5) Good (4) Average (3) Fair (2) Poor (1)
No. Indicator
Student knows very
Student knows all Student knows most
Student knows few of little about the Student has poor
the related of the related
the related concepts related concepts understanding of the
concepts about the concepts about the
about the theoretical about the related concepts about
theoretical theoretical
Theoretical background of the theoretical the theoretical
background of the background of the
1 knowledge experiment and background of the background of the
experiment and experiment and
10% partially rephrase experiment and experiment and unable
rephrase those partially rephrase
those concepts in poorly rephrase to rephrase those
concepts in written those concepts in
written and oral those concepts in concepts in written
and oral written and oral
assessments written and oral and oral assessments
assessments assessments
assessments
Application Application Application does
Application compiles with few compiles and not compile or
Application runs
compiles with no or no warnings. runs without compiles but
Application smoothly and
warnings. Robust Consideration crashing. Some crashes.
2 Functionality operation of the
operation of the given to unusual attempt at Confusing. Little
10% application runs
application, with conditions with detecting and or no error
efficiently
good recovery. reasonable correcting detection or
recovery errors. correction.
The program works
The program
and produces the The program
works very
The program works correct results and produces correct The program is
Specifications efficiently and
3 and meets some of displays them results but does not producing incorrect
10% meets all of the
the specifications. correctly. It also display them results.
required
meets most of the correctly.
specifications.
other specifications.
Provide complete Provide complete Provide partially
Level of and logical and logical answers correct and logical Provide very few
understanding answers based based upon accurate answers based upon and illogical Provide no answer to

4 of the learned upon accurate technical content to minimum technical answers to the the questions asked by
skill technical content the questions asked content to the questions asked by examiner.

10% to the questions by examiner with questions asked by examiner.


asked by examiner few errors examiner
The code is fairly
The code is Some parts of the The code is poorly
Readability easy to read. The
exceptionally well Most of the code code require organized and very
and code could be reused
5 organized and could be reused in change before they difficult to read and
Reusability as a whole or each
very easy to other programs. could be reused in not organized for
10% class could be
follow and reused other programs. reusability.
reused.
The University of Lahore Department of Technology

Some attempt at
Little attempt at
Well-designed Good data layering data. Some Very poor attempt and
layering data.
Object classes with good abstraction and some generalization of missing code. Code is
Missing, duplicate
Oriented data abstraction data layering. Good interface evident but maintenance
6 or not useful class
Design and layering. Code set of operations missed opportunity. headache. No OOP
interface. Some
10% is highly provided. Little Code can be language feature is
OOP language
maintainable duplications maintained with used
feature is used
significant effort
1. Responds well,
quick and very
1. Generally
accurate all the 1. Not much
Responsive and 1. Generally 1. Non-Responsive
time. Responsive and
accurate most of the Responsive and and inaccurate all the
Responsiveness 2. Effectively uses accurate most of
times. accurate few times. times.
to Questions/ eye contact, the times.
7 2. Maintains eye 2. Some eye contact, 2. No eye contact and
Accuracy speaks clearly, 2. Uses eye contact
contact, speaks speaks clearly and unable to speak
10% effectively and ineffectively and
clearly with suitable unclearly in different 3. Dresses
confidently using fails to speak
volume and pace. portions. inappropriately
suitable volume clearly and audibly
and pace.

Some part of the code


The code is The code is fairly
is efficient and other
extremely efficient efficient without The code is brute The code is huge and
Efficiency part of the code is not
8 without sacrificing sacrificing force and appears to be patched
10% understandable and
readability and readability and unnecessarily long together
work properly
understanding understanding

The code was


The program was The program was The program was The code was
Delivery delivered within a
9 delivered in time delivered in Lab delivered within the delivered more than 2
10% day after the due
during lab. before the end time. due date. days overdue.
date.
Student has
Student has Student has little Student has little
sufficient Student has no
sufficient knowledge knowledge of the knowledge of the
Awareness of knowledge of the knowledge of the
of the laboratory laboratory safety laboratory safety
Safety laboratory safety laboratory safety
10 safety SOPs and SOPs and protocol SOPs and protocol
Guidelines SOPs and protocol SOPs and protocol
protocol and is and is Partially and is non-
10% and is fully and is non-compliant
Partially compliant compliant to the compliant to the
compliant to the to the guidelines
to the guidelines guidelines guidelines
guidelines
Lab No. 9
To apply and analyze various sorting algorithms in C++ for
optimizing data organization.

Objective :
In a C++ Understand the working of various sorting algorithms . Implement and
compare the performance of sorting techniques.Explore the applications of sorting in
data organization.These objectives focus on both understanding the theoretical
concepts of sorting algorithms and gaining practical programming skills to manipulate
these algorithms.
Tools:
Dev C++
Background Knowledge:
Sorting is the process of arranging data in a specific order, either ascending or
descending. Sorting is crucial in computer science for optimizing search algorithms
and organizing data.
Types of Sorting Algorithms:
Bubble Sort - Repeatedly compares adjacent elements and swaps them if they are in
the wrong order.
Selection Sort - Finds the smallest element in the array and places it at the beginning.
Insertion Sort - Builds the sorted array one element at a time by inserting it in the
correct position.
Merge Sort - Divides the array into halves, recursively sorts them, and merges the
sorted halves.
Quick Sort - Divides the array using a pivot, then recursively sorts the partitions.
Heap Sort - Uses a binary heap structure to sort the array.
Sample Tasks
Task 1
Write a program to Implement the Bubble Sort algorithm.
#include <iostream>
using namespace std;
void bubbleSort(int arr[], int n) {
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (arr[j] > arr[j + 1]) {
// Swap arr[j] and arr[j+1]
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}

int main() {
int arr[] = {64, 34, 25, 12, 22, 11, 90};
int n = sizeof(arr) / sizeof(arr[0]);

bubbleSort(arr, n);

cout << "Sorted array: ";


for (int i = 0; i < n; i++)
cout << arr[i] << " ";
return 0;
}

Task 2
Write a program that implement the Selection Sort algorithm.
#include <iostream>
using namespace std;
void selectionSort(int arr[], int n) {
for (int i = 0; i < n - 1; i++) {
int minIndex = i;
for (int j = i + 1; j < n; j++) {
if (arr[j] < arr[minIndex])
minIndex = j;
}
// Swap the found minimum element with the first element
int temp = arr[minIndex];
arr[minIndex] = arr[i];
arr[i] = temp;
}
}

int main() {
int arr[] = {29, 10, 14, 37, 13};
int n = sizeof(arr) / sizeof(arr[0]);
selectionSort(arr, n);
cout << "Sorted array: ";
for (int i = 0; i < n; i++)
cout << arr[i] << " ";
return 0;
}

Task 3
Write a program to implement Insertion Sort in C++.
#include <iostream>
using namespace std;
void insertionSort(int arr[], int n) {
for (int i = 1; i < n; i++) {
int key = arr[i];
int j = i - 1;
// Move elements of arr[0..i-1], that are greater than key, one position ahead
while (j >= 0 && arr[j] > key) {
arr[j + 1] = arr[j];
j--;
}
arr[j + 1] = key;
}
}

int main() {
int arr[] = {12, 11, 13, 5, 6};
int n = sizeof(arr) / sizeof(arr[0]);
insertionSort(arr, n);
cout << "Sorted array: ";
for (int i = 0; i < n; i++)
cout << arr[i] << " ";
cout << endl;

return 0;
}

Exercise :
Exercise 1:
Write a program to implement Merge Sort in C++.
Solution:

#include <iostream>
using namespace std;

void merge(int arr[], int l, int m, int r) {


int n1 = m - l + 1;
int n2 = r - m;

int* L = new int[n1];


int* R = new int[n2];
for (int i = 0; i < n1; i++)
L[i] = arr[l + i];
for (int j = 0; j < n2; j++)
R[j] = arr[m + 1 + j];

int i = 0, j = 0, k = l;

while (i < n1 && j < n2) {


if (L[i] <= R[j]) {
arr[k++] = L[i++];
}
else {
arr[k++] = R[j++];
}
}

while (i < n1) {


arr[k++] = L[i++];
}

while (j < n2) {


arr[k++] = R[j++];
}

delete[] L;
delete[] R;
}

void mergeSort(int arr[], int l, int r) {


if (l < r) {
int m = l + (r - l) / 2;
mergeSort(arr, l, m);
mergeSort(arr, m + 1, r);
merge(arr, l, m, r);
}
}

int main() {
int n;
cout << "Enter number of elements: ";
cin >> n;

int* arr = new int[n];


cout << "Enter " << n << " elements:\n";
for (int i = 0; i < n; i++)
cin >> arr[i];

mergeSort(arr, 0, n - 1);

cout << "Sorted array:\n";


for (int i = 0; i < n; i++)
cout << arr[i] << " ";
cout << endl;

delete[] arr;
return 0;
}

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 2
Write a program to implement quick Sort.
Solution:
#include <iostream>
using namespace std;

int partition(int arr[], int low, int high) {


int pivot = arr[high];
int i = low - 1;

for (int j = low; j < high; j++) {


if (arr[j] <= pivot) {
i++;
swap(arr[i], arr[j]);
}
}
swap(arr[i + 1], arr[high]);
return i + 1;
}

void quickSort(int arr[], int low, int high) {


if (low < high) {
int pi = partition(arr, low, high);

quickSort(arr, low, pi - 1);


quickSort(arr, pi + 1, high);
}
}

int main() {
int n;
cout << "Enter number of elements: ";
cin >> n;

int* arr = new int[n];


cout << "Enter " << n << " elements:\n";
for (int i = 0; i < n; i++)
cin >> arr[i];
quickSort(arr, 0, n - 1);

cout << "Sorted array:\n";


for (int i = 0; i < n; i++)
cout << arr[i] << " ";
cout << endl;

delete[] arr;
return 0;
}

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

FINAL EVALUTION LAB 09


Student Name:

Registration Number:

Date:

Marks Obtained Total Marks

Instructor Signatures:

Remarks:
The University of Lahore Department of Technology

Laboratory Work Assessment Rubrics


Sr. Performance
Excellent (5) Good (4) Average (3) Fair (2) Poor (1)
No. Indicator
Student knows very
Student knows all Student knows most
Student knows few of little about the Student has poor
the related of the related
the related concepts related concepts understanding of the
concepts about the concepts about the
about the theoretical about the related concepts about
theoretical theoretical
Theoretical background of the theoretical the theoretical
background of the background of the
1 knowledge experiment and background of the background of the
experiment and experiment and
10% partially rephrase experiment and experiment and unable
rephrase those partially rephrase
those concepts in poorly rephrase to rephrase those
concepts in written those concepts in
written and oral those concepts in concepts in written
and oral written and oral
assessments written and oral and oral assessments
assessments assessments
assessments
Application Application Application does
Application compiles with few compiles and not compile or
Application runs
compiles with no or no warnings. runs without compiles but
Application smoothly and
warnings. Robust Consideration crashing. Some crashes.
2 Functionality operation of the
operation of the given to unusual attempt at Confusing. Little
10% application runs
application, with conditions with detecting and or no error
efficiently
good recovery. reasonable correcting detection or
recovery errors. correction.
The program works
The program
and produces the The program
works very
The program works correct results and produces correct The program is
Specifications efficiently and
3 and meets some of displays them results but does not producing incorrect
10% meets all of the
the specifications. correctly. It also display them results.
required
meets most of the correctly.
specifications.
other specifications.
Provide complete Provide complete Provide partially
Level of and logical and logical answers correct and logical Provide very few
understanding answers based based upon accurate answers based upon and illogical Provide no answer to

4 of the learned upon accurate technical content to minimum technical answers to the the questions asked by
skill technical content the questions asked content to the questions asked by examiner.

10% to the questions by examiner with questions asked by examiner.


asked by examiner few errors examiner
The code is fairly
The code is Some parts of the The code is poorly
Readability easy to read. The
exceptionally well Most of the code code require organized and very
and code could be reused
5 organized and could be reused in change before they difficult to read and
Reusability as a whole or each
very easy to other programs. could be reused in not organized for
10% class could be
follow and reused other programs. reusability.
reused.
The University of Lahore Department of Technology

Some attempt at
Little attempt at
Well-designed Good data layering data. Some Very poor attempt and
layering data.
Object classes with good abstraction and some generalization of missing code. Code is
Missing, duplicate
Oriented data abstraction data layering. Good interface evident but maintenance
6 or not useful class
Design and layering. Code set of operations missed opportunity. headache. No OOP
interface. Some
10% is highly provided. Little Code can be language feature is
OOP language
maintainable duplications maintained with used
feature is used
significant effort
1. Responds well,
quick and very
1. Generally
accurate all the 1. Not much
Responsive and 1. Generally 1. Non-Responsive
time. Responsive and
accurate most of the Responsive and and inaccurate all the
Responsiveness 2. Effectively uses accurate most of
times. accurate few times. times.
to Questions/ eye contact, the times.
7 2. Maintains eye 2. Some eye contact, 2. No eye contact and
Accuracy speaks clearly, 2. Uses eye contact
contact, speaks speaks clearly and unable to speak
10% effectively and ineffectively and
clearly with suitable unclearly in different 3. Dresses
confidently using fails to speak
volume and pace. portions. inappropriately
suitable volume clearly and audibly
and pace.

Some part of the code


The code is The code is fairly
is efficient and other
extremely efficient efficient without The code is brute The code is huge and
Efficiency part of the code is not
8 without sacrificing sacrificing force and appears to be patched
10% understandable and
readability and readability and unnecessarily long together
work properly
understanding understanding

The code was


The program was The program was The program was The code was
Delivery delivered within a
9 delivered in time delivered in Lab delivered within the delivered more than 2
10% day after the due
during lab. before the end time. due date. days overdue.
date.
Student has
Student has Student has little Student has little
sufficient Student has no
sufficient knowledge knowledge of the knowledge of the
Awareness of knowledge of the knowledge of the
of the laboratory laboratory safety laboratory safety
Safety laboratory safety laboratory safety
10 safety SOPs and SOPs and protocol SOPs and protocol
Guidelines SOPs and protocol SOPs and protocol
protocol and is and is Partially and is non-
10% and is fully and is non-compliant
Partially compliant compliant to the compliant to the
compliant to the to the guidelines
to the guidelines guidelines guidelines
guidelines
Lab No. 10
To explore and implement different searching algorithms in C++ for
effective data retrieval
Objective :
Understand and implement searching algorithms in C++.Analyze and compare the
efficiency of various searching techniques by using different concepts of C++.These
objectives focus on both understanding the theoretical concepts of matrices and
gaining practical programming skills to manipulate matrices.
Tools:
Dev C++
Background Knowledge:
Searching is the process of finding the position of a target element in a collection
(array, list, etc.).
Types of Searching Algorithms:
Linear Search: Sequentially checks each element until the target element is found or
the list ends.
Binary Search: Divides a sorted array into halves to locate the target element.
Sample Tasks
Task 1
Write a program to implement Linear Search.
#include <iostream>
using namespace std;
int linearSearch(int arr[], int n, int key) {
for (int i = 0; i < n; i++) {
if (arr[i] == key)
return i; // Return the index of the element
}
return -1; // Element not found
}

int main() {
int arr[] = {10, 23, 45, 70, 11, 15};
int n = sizeof(arr) / sizeof(arr[0]);
int key = 70;
int result = linearSearch(arr, n, key);
if (result != -1)
cout << "Element found at index " << result << endl;
else
cout << "Element not found" << endl;

return 0;
}

Task 2
Write a program to implement Binary Search in C++.
#include <iostream>
using namespace std;

int binarySearch(int arr[], int low, int high, int key) {


while (low <= high) {
int mid = low + (high - low) / 2;

if (arr[mid] == key)
return mid; // Element found
else if (arr[mid] < key)
low = mid + 1; // Search in the right half
else
high = mid - 1; // Search in the left half
}
return -1; // Element not found
}

int main() {
int arr[] = {10, 20, 30, 40, 50, 60, 70};
int n = sizeof(arr) / sizeof(arr[0]);
int key = 50;
int result = binarySearch(arr, 0, n - 1, key);
if (result != -1)
cout << "Element found at index " << result << endl;
else
cout << "Element not found" << endl;

return 0;
}

Exercise :
Exercise 1:
Write a program that modify the Binary Search program to find the last occurrence of
an element in a sorted array.
Solution:

#include <iostream>
using namespace std;

int lastOccurrence(int arr[], int n, int x) {


int low = 0, high = n - 1;
int result = -1;

while (low <= high) {


int mid = low + (high - low) / 2;

if (arr[mid] == x) {
result = mid; // Record this occurrence
low = mid + 1; // Search to the right to find last occurrence
} else if (arr[mid] < x) {
low = mid + 1;
} else {
high = mid - 1;
}
}

return result;
}

int main() {
int n;
cout << "Enter number of elements: ";
cin >> n;

int* arr = new int[n];


cout << "Enter sorted elements:\n";
for (int i = 0; i < n; i++)
cin >> arr[i];

int x;
cout << "Enter element to find last occurrence: ";
cin >> x;

int index = lastOccurrence(arr, n, x);

if (index != -1)
cout << "Last occurrence of " << x << " is at index " << index << endl;
else
cout << x << " not found in the array." << endl;

delete[] arr;
return 0;
}

Marks Obtained Total Marks


Instructor Signatures:

Remarks:

Exercise 2
Write a program that implement a recursive version of Binary Search.
Solution:

#include <iostream>
using namespace std;

int recursiveBinarySearch(int arr[], int low, int high, int x) {


if (low > high)
return -1;

int mid = low + (high - low) / 2;

if (arr[mid] == x)
return mid;
else if (arr[mid] > x)
return recursiveBinarySearch(arr, low, mid - 1, x);
else
return recursiveBinarySearch(arr, mid + 1, high, x);
}

int main() {
int n;
cout << "Enter number of elements: ";
cin >> n;

int* arr = new int[n];


cout << "Enter sorted elements:\n";
for (int i = 0; i < n; i++)
cin >> arr[i];
int x;
cout << "Enter element to search: ";
cin >> x;

int index = recursiveBinarySearch(arr, 0, n - 1, x);

if (index != -1)
cout << "Element " << x << " found at index " << index << endl;
else
cout << "Element not found in the array." << endl;

delete[] arr;
return 0;
}

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

FINAL EVALUTION LAB 10

Student Name:

Registration Number:

Date:

Marks Obtained Total Marks

Instructor Signatures:
Remarks:
The University of Lahore Department of Technology

Laboratory Work Assessment Rubrics


Sr. Performance
Excellent (5) Good (4) Average (3) Fair (2) Poor (1)
No. Indicator
Student knows very
Student knows all Student knows most
Student knows few of little about the Student has poor
the related of the related
the related concepts related concepts understanding of the
concepts about the concepts about the
about the theoretical about the related concepts about
theoretical theoretical
Theoretical background of the theoretical the theoretical
background of the background of the
1 knowledge experiment and background of the background of the
experiment and experiment and
10% partially rephrase experiment and experiment and unable
rephrase those partially rephrase
those concepts in poorly rephrase to rephrase those
concepts in written those concepts in
written and oral those concepts in concepts in written
and oral written and oral
assessments written and oral and oral assessments
assessments assessments
assessments
Application Application Application does
Application compiles with few compiles and not compile or
Application runs
compiles with no or no warnings. runs without compiles but
Application smoothly and
warnings. Robust Consideration crashing. Some crashes.
2 Functionality operation of the
operation of the given to unusual attempt at Confusing. Little
10% application runs
application, with conditions with detecting and or no error
efficiently
good recovery. reasonable correcting detection or
recovery errors. correction.
The program works
The program
and produces the The program
works very
The program works correct results and produces correct The program is
Specifications efficiently and
3 and meets some of displays them results but does not producing incorrect
10% meets all of the
the specifications. correctly. It also display them results.
required
meets most of the correctly.
specifications.
other specifications.
Provide complete Provide complete Provide partially
Level of and logical and logical answers correct and logical Provide very few
understanding answers based based upon accurate answers based upon and illogical Provide no answer to

4 of the learned upon accurate technical content to minimum technical answers to the the questions asked by
skill technical content the questions asked content to the questions asked by examiner.

10% to the questions by examiner with questions asked by examiner.


asked by examiner few errors examiner
The code is fairly
The code is Some parts of the The code is poorly
Readability easy to read. The
exceptionally well Most of the code code require organized and very
and code could be reused
5 organized and could be reused in change before they difficult to read and
Reusability as a whole or each
very easy to other programs. could be reused in not organized for
10% class could be
follow and reused other programs. reusability.
reused.
The University of Lahore Department of Technology

Some attempt at
Little attempt at
Well-designed Good data layering data. Some Very poor attempt and
layering data.
Object classes with good abstraction and some generalization of missing code. Code is
Missing, duplicate
Oriented data abstraction data layering. Good interface evident but maintenance
6 or not useful class
Design and layering. Code set of operations missed opportunity. headache. No OOP
interface. Some
10% is highly provided. Little Code can be language feature is
OOP language
maintainable duplications maintained with used
feature is used
significant effort
1. Responds well,
quick and very
1. Generally
accurate all the 1. Not much
Responsive and 1. Generally 1. Non-Responsive
time. Responsive and
accurate most of the Responsive and and inaccurate all the
Responsiveness 2. Effectively uses accurate most of
times. accurate few times. times.
to Questions/ eye contact, the times.
7 2. Maintains eye 2. Some eye contact, 2. No eye contact and
Accuracy speaks clearly, 2. Uses eye contact
contact, speaks speaks clearly and unable to speak
10% effectively and ineffectively and
clearly with suitable unclearly in different 3. Dresses
confidently using fails to speak
volume and pace. portions. inappropriately
suitable volume clearly and audibly
and pace.

Some part of the code


The code is The code is fairly
is efficient and other
extremely efficient efficient without The code is brute The code is huge and
Efficiency part of the code is not
8 without sacrificing sacrificing force and appears to be patched
10% understandable and
readability and readability and unnecessarily long together
work properly
understanding understanding

The code was


The program was The program was The program was The code was
Delivery delivered within a
9 delivered in time delivered in Lab delivered within the delivered more than 2
10% day after the due
during lab. before the end time. due date. days overdue.
date.
Student has
Student has Student has little Student has little
sufficient Student has no
sufficient knowledge knowledge of the knowledge of the
Awareness of knowledge of the knowledge of the
of the laboratory laboratory safety laboratory safety
Safety laboratory safety laboratory safety
10 safety SOPs and SOPs and protocol SOPs and protocol
Guidelines SOPs and protocol SOPs and protocol
protocol and is and is Partially and is non-
10% and is fully and is non-compliant
Partially compliant compliant to the compliant to the
compliant to the to the guidelines
to the guidelines guidelines guidelines
guidelines
Lab No. 11
An introduction to the role of functions in C++ programming,
with a focus on their application within discrete structures and
algorithm design.
Objective :
To understand and implement various types of functions in C++, including function
definition, function overloading, passing arguments, returning values, and recursion.
Tools:
Dev C++
Background Knowledge:
A function is a block of code which only runs when it is called.You can pass data,
known as parameters, into a function.Functions are used to perform certain actions, and
they are important for reusing code: Define the code once, and use it many times.
To create (often referred to as declare) a function, specify the name of the function,
followed by parentheses ():
void myFunction() {
// code to be executed
}

Example Explained

• myFunction() is the name of the function


• void means that the function does not have a return value. You will learn more
about return values later in the next chapter
• inside the function (the body), add code that defines what the function should
do.

Declared functions are not executed immediately. They are "saved for later use",
and will be executed later, when they are called.To call a function, write the
function's name followed by two parentheses () and a semicolon ;

Sample Tasks
Task 1
Write a program to define and call a simple function in C++.
#include <iostream>
using namespace std;
// Function declaration
void greet() {
cout << "Hello, welcome to C++ functions!" << endl;
}
int main() {
greet(); // Function call
return 0;
}

Task 2
Write a program to calculate the sum of any two numbers by using functions in
C++.
#include <iostream>
using namespace std;

void add(int a, int b) {


cout << "The sum is: " << a + b << endl;
}

int main() {
add(5, 10); // Function call
return 0;
}

Task 3
Write a program to multiply any two numbers and print the result on the output
screen by creating a function that returns a value.
#include <iostream>
using namespace std;

int multiply(int x, int y) {


return x * y;
}

int main() {
int result = multiply(4, 5);
cout << "The product is: " << result << endl;
return 0;}

Task 4
Write a program to demonstrate pass by reference concept and implement
swapping of two values by using functions in C++.
#include <iostream>
using namespace std;

void swap(int &a, int &b) {


int temp = a;
a = b;
b = temp;
}

int main() {
int x = 10, y = 20;
cout << "Before swapping: x = " << x << ", y = " << y << endl;
swap(x, y);
cout << "After swapping: x = " << x << ", y = " << y << endl;
return 0;
}
Task 5
Write a program to find the sum of elements in an array passed to a function.
#include <iostream>
using namespace std;

int sumArray(int arr[], int size) {


int sum = 0;
for (int i = 0; i < size; i++) {
sum += arr[i];
}
return sum;
}

int main() {
int numbers[] = {1, 2, 3, 4, 5};
int size = sizeof(numbers) / sizeof(numbers[0]);
cout << "Sum of the array is: " << sumArray(numbers, size) << endl;
return 0;
}

Task 6
Write a program to double the values of elements in an array using a function.
#include <iostream>
using namespace std;

void doubleArray(int arr[], int size) {


for (int i = 0; i < size; i++) {
arr[i] *= 2;
}
}

int main() {
int numbers[] = {1, 2, 3, 4, 5};
int size = sizeof(numbers) / sizeof(numbers[0]);

cout << "Original array: ";


for (int i = 0; i < size; i++) {
cout << numbers[i] << " ";
}
cout << endl;

doubleArray(numbers, size);

cout << "Doubled array: ";


for (int i = 0; i < size; i++) {
cout << numbers[i] << " ";
}
cout << endl;
return 0;
}

Exercise :
Exercise 1:
Write a program to calculate the total price of items with a default discount by
using functions in C++.
Solution:
Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 2
Write a program to calculate the average of an array with a fixed size passed to a
function.
Solution:
Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 3
Write a program to convert temperature from farenhite to celcius using functions
in C++.
Solution:
Marks Obtained Total Marks

Instructor Signatures:

Remarks:

FINAL EVALUTION LAB 11


Student Name:

Registration Number:

Date:

Marks Obtained Total Marks

Instructor Signatures:

Remarks:
The University of Lahore Department of Technology

Laboratory Work Assessment Rubrics


Sr. Performance
Excellent (5) Good (4) Average (3) Fair (2) Poor (1)
No. Indicator
Student knows very
Student knows all Student knows most
Student knows few of little about the Student has poor
the related of the related
the related concepts related concepts understanding of the
concepts about the concepts about the
about the theoretical about the related concepts about
theoretical theoretical
Theoretical background of the theoretical the theoretical
background of the background of the
1 knowledge experiment and background of the background of the
experiment and experiment and
10% partially rephrase experiment and experiment and unable
rephrase those partially rephrase
those concepts in poorly rephrase to rephrase those
concepts in written those concepts in
written and oral those concepts in concepts in written
and oral written and oral
assessments written and oral and oral assessments
assessments assessments
assessments
Application Application Application does
Application compiles with few compiles and not compile or
Application runs
compiles with no or no warnings. runs without compiles but
Application smoothly and
warnings. Robust Consideration crashing. Some crashes.
2 Functionality operation of the
operation of the given to unusual attempt at Confusing. Little
10% application runs
application, with conditions with detecting and or no error
efficiently
good recovery. reasonable correcting detection or
recovery errors. correction.
The program works
The program
and produces the The program
works very
The program works correct results and produces correct The program is
Specifications efficiently and
3 and meets some of displays them results but does not producing incorrect
10% meets all of the
the specifications. correctly. It also display them results.
required
meets most of the correctly.
specifications.
other specifications.
Provide complete Provide complete Provide partially
Level of and logical and logical answers correct and logical Provide very few
understanding answers based based upon accurate answers based upon and illogical Provide no answer to

4 of the learned upon accurate technical content to minimum technical answers to the the questions asked by
skill technical content the questions asked content to the questions asked by examiner.

10% to the questions by examiner with questions asked by examiner.


asked by examiner few errors examiner
The code is fairly
The code is Some parts of the The code is poorly
Readability easy to read. The
exceptionally well Most of the code code require organized and very
and code could be reused
5 organized and could be reused in change before they difficult to read and
Reusability as a whole or each
very easy to other programs. could be reused in not organized for
10% class could be
follow and reused other programs. reusability.
reused.
The University of Lahore Department of Technology

Some attempt at
Little attempt at
Well-designed Good data layering data. Some Very poor attempt and
layering data.
Object classes with good abstraction and some generalization of missing code. Code is
Missing, duplicate
Oriented data abstraction data layering. Good interface evident but maintenance
6 or not useful class
Design and layering. Code set of operations missed opportunity. headache. No OOP
interface. Some
10% is highly provided. Little Code can be language feature is
OOP language
maintainable duplications maintained with used
feature is used
significant effort
1. Responds well,
quick and very
1. Generally
accurate all the 1. Not much
Responsive and 1. Generally 1. Non-Responsive
time. Responsive and
accurate most of the Responsive and and inaccurate all the
Responsiveness 2. Effectively uses accurate most of
times. accurate few times. times.
to Questions/ eye contact, the times.
7 2. Maintains eye 2. Some eye contact, 2. No eye contact and
Accuracy speaks clearly, 2. Uses eye contact
contact, speaks speaks clearly and unable to speak
10% effectively and ineffectively and
clearly with suitable unclearly in different 3. Dresses
confidently using fails to speak
volume and pace. portions. inappropriately
suitable volume clearly and audibly
and pace.

Some part of the code


The code is The code is fairly
is efficient and other
extremely efficient efficient without The code is brute The code is huge and
Efficiency part of the code is not
8 without sacrificing sacrificing force and appears to be patched
10% understandable and
readability and readability and unnecessarily long together
work properly
understanding understanding

The code was


The program was The program was The program was The code was
Delivery delivered within a
9 delivered in time delivered in Lab delivered within the delivered more than 2
10% day after the due
during lab. before the end time. due date. days overdue.
date.
Student has
Student has Student has little Student has little
sufficient Student has no
sufficient knowledge knowledge of the knowledge of the
Awareness of knowledge of the knowledge of the
of the laboratory laboratory safety laboratory safety
Safety laboratory safety laboratory safety
10 safety SOPs and SOPs and protocol SOPs and protocol
Guidelines SOPs and protocol SOPs and protocol
protocol and is and is Partially and is non-
10% and is fully and is non-compliant
Partially compliant compliant to the compliant to the
compliant to the to the guidelines
to the guidelines guidelines guidelines
guidelines
Lab No. 12
To explore recursive functions in C++ and understand their role in
handling sequences and discrete structures in algorithmic problem-solving

Objective :
he goal of this lab manual is to help students understand and implement recursive
functions in C++. By solving various tasks, students will learn how recursion simplifies
complex problems and when to use it effectively. The manual also aims to emphasize
the importance of base cases and stack memory in recursive calls.
Tools:
Dev C++
Background Knowledge:
A function is a block of code which only runs when it is called.You can pass data,
known as parameters, into a function.Functions are used to perform certain actions, and
they are important for reusing code: Define the code once, and use it many times.
To create (often referred to as declare) a function, specify the name of the function,
followed by parentheses ():
void myFunction() {
// code to be executed
}

Example Explained

• myFunction() is the name of the function


• void means that the function does not have a return value. You will learn more
about return values later in the next chapter
• inside the function (the body), add code that defines what the function should
do.

Declared functions are not executed immediately. They are "saved for later use",
and will be executed later, when they are called.To call a function, write the
function's name followed by two parentheses () and a semicolon ;

Sample Tasks
Task 1
Write a program to calculate the factorial of a number using recursion. in C++.
#include <iostream>
using namespace std;

int factorial(int n) {
if (n == 0) // Base case
return 1;
return n * factorial(n - 1); // Recursive call
}

int main() {
int num;
cout << "Enter a number: ";
cin >> num;

cout << "Factorial of " << num << " is: " << factorial(num) << endl;
return 0;
}

Task 2
Write a program to Generate the Fibonacci sequence using recursion in C++.
#include <iostream>
using namespace std;

int fibonacci(int n) {
if (n == 0) return 0; // Base case
if (n == 1) return 1; // Base case
return fibonacci(n - 1) + fibonacci(n - 2); // Recursive call
}

int main() {
int n;
cout << "Enter the position of Fibonacci number: ";
cin >> n;

cout << "Fibonacci number at position " << n << " is: " << fibonacci(n) << endl;
return 0;
}

Exercise :
Exercise 1:
Write a program to find the greatest common divisor (GCD) of two numbers using
recursion. in C++.
Solution:

Marks Obtained Total Marks

Instructor Signatures:

Remarks:
FINAL EVALUTION LAB 12

Student Name:

Registration Number:

Date:

Marks Obtained Total Marks

Instructor Signatures:

Remarks:
The University of Lahore Department of Technology

Laboratory Work Assessment Rubrics


Sr. Performance
Excellent (5) Good (4) Average (3) Fair (2) Poor (1)
No. Indicator
Student knows very
Student knows all Student knows most
Student knows few of little about the Student has poor
the related of the related
the related concepts related concepts understanding of the
concepts about the concepts about the
about the theoretical about the related concepts about
theoretical theoretical
Theoretical background of the theoretical the theoretical
background of the background of the
1 knowledge experiment and background of the background of the
experiment and experiment and
10% partially rephrase experiment and experiment and unable
rephrase those partially rephrase
those concepts in poorly rephrase to rephrase those
concepts in written those concepts in
written and oral those concepts in concepts in written
and oral written and oral
assessments written and oral and oral assessments
assessments assessments
assessments
Application Application Application does
Application compiles with few compiles and not compile or
Application runs
compiles with no or no warnings. runs without compiles but
Application smoothly and
warnings. Robust Consideration crashing. Some crashes.
2 Functionality operation of the
operation of the given to unusual attempt at Confusing. Little
10% application runs
application, with conditions with detecting and or no error
efficiently
good recovery. reasonable correcting detection or
recovery errors. correction.
The program works
The program
and produces the The program
works very
The program works correct results and produces correct The program is
Specifications efficiently and
3 and meets some of displays them results but does not producing incorrect
10% meets all of the
the specifications. correctly. It also display them results.
required
meets most of the correctly.
specifications.
other specifications.
Provide complete Provide complete Provide partially
Level of and logical and logical answers correct and logical Provide very few
understanding answers based based upon accurate answers based upon and illogical Provide no answer to

4 of the learned upon accurate technical content to minimum technical answers to the the questions asked by
skill technical content the questions asked content to the questions asked by examiner.

10% to the questions by examiner with questions asked by examiner.


asked by examiner few errors examiner
The code is fairly
The code is Some parts of the The code is poorly
Readability easy to read. The
exceptionally well Most of the code code require organized and very
and code could be reused
5 organized and could be reused in change before they difficult to read and
Reusability as a whole or each
very easy to other programs. could be reused in not organized for
10% class could be
follow and reused other programs. reusability.
reused.
The University of Lahore Department of Technology

Some attempt at
Little attempt at
Well-designed Good data layering data. Some Very poor attempt and
layering data.
Object classes with good abstraction and some generalization of missing code. Code is
Missing, duplicate
Oriented data abstraction data layering. Good interface evident but maintenance
6 or not useful class
Design and layering. Code set of operations missed opportunity. headache. No OOP
interface. Some
10% is highly provided. Little Code can be language feature is
OOP language
maintainable duplications maintained with used
feature is used
significant effort
1. Responds well,
quick and very
1. Generally
accurate all the 1. Not much
Responsive and 1. Generally 1. Non-Responsive
time. Responsive and
accurate most of the Responsive and and inaccurate all the
Responsiveness 2. Effectively uses accurate most of
times. accurate few times. times.
to Questions/ eye contact, the times.
7 2. Maintains eye 2. Some eye contact, 2. No eye contact and
Accuracy speaks clearly, 2. Uses eye contact
contact, speaks speaks clearly and unable to speak
10% effectively and ineffectively and
clearly with suitable unclearly in different 3. Dresses
confidently using fails to speak
volume and pace. portions. inappropriately
suitable volume clearly and audibly
and pace.

Some part of the code


The code is The code is fairly
is efficient and other
extremely efficient efficient without The code is brute The code is huge and
Efficiency part of the code is not
8 without sacrificing sacrificing force and appears to be patched
10% understandable and
readability and readability and unnecessarily long together
work properly
understanding understanding

The code was


The program was The program was The program was The code was
Delivery delivered within a
9 delivered in time delivered in Lab delivered within the delivered more than 2
10% day after the due
during lab. before the end time. due date. days overdue.
date.
Student has
Student has Student has little Student has little
sufficient Student has no
sufficient knowledge knowledge of the knowledge of the
Awareness of knowledge of the knowledge of the
of the laboratory laboratory safety laboratory safety
Safety laboratory safety laboratory safety
10 safety SOPs and SOPs and protocol SOPs and protocol
Guidelines SOPs and protocol SOPs and protocol
protocol and is and is Partially and is non-
10% and is fully and is non-compliant
Partially compliant compliant to the compliant to the
compliant to the to the guidelines
to the guidelines guidelines guidelines
guidelines
Lab No. 13
Open Ended Lab

Objective :
he goal of this lab manual is to understand and implement different concepts of
discrete structures i in C++. By solving various tasks, students will learn how
simplifies complex problems and when to use it effectively.
Tools:
Dev C++
Exercise 1:
Truth Table Generator
Objective: Implement a program to generate a truth table for a given logical
expression.
Problem Statement:
Create a program that takes a logical expression (e.g., A∧B∨¬AA \land B \lor \neg
AA∧B∨¬A) and generates a truth table. Allow users to input the number of variables
and the logical expression.
Hints:
Use arrays to store variable values for each row of the truth table.
Implement operators like AND (&&), OR (||), and NOT (!).
Solution:

#include <iostream>
using namespace std;

bool evaluateExpression(bool A, bool B) {


return (A && B) || !A;
}

int main() {
bool A, B;

cout << "Truth Table for expression: (A && B) || !A\n";


cout << "A\tB\tResult\n";
cout << "---------------------\n";
for (int i = 0; i < 2; i++) {
A = i;
for (int j = 0; j < 2; j++) {
B = j;
bool result = evaluateExpression(A, B);
cout << A << "\t" << B << "\t" << result << endl;
}
}

return 0;
}

Marks Obtained Total Marks

Instructor Signatures:

Remarks:

Exercise 2:
Solving Recurrence Relations
Objective: Implement solutions to recurrence relations programmatically.
Scenario:
Write a program to solve recurrence relations like:
1. Fibonacci sequence (T(n)=T(n−1)+T(n−2)T(n) = T(n-1) + T(n-
2)T(n)=T(n−1)+T(n−2))
2. Towers of Hanoi (T(n)=2T(n−1)+1T(n) = 2T(n-1) + 1T(n)=2T(n−1)+1)
3. Any custom recurrence relation provided as input.

Extension Task: Verify results using closed-form solutions.

Solution:

#include <iostream>
#include <cmath>
using namespace std;

int fibonacci(int n) {
if (n == 0) return 0;
if (n == 1) return 1;
return fibonacci(n - 1) + fibonacci(n - 2);
}

int fibonacciClosed(int n) {
double phi = (1 + sqrt(5)) / 2;
return round(pow(phi, n) / sqrt(5));
}

int towerOfHanoi(int n) {
if (n == 1) return 1;
return 2 * towerOfHanoi(n - 1) + 1;
}

int towerOfHanoiClosed(int n) {
return (1 << n) - 1;
}

int main() {
int choice, n;
cout << "Choose recurrence:\n";
cout << "1. Fibonacci\n";
cout << "2. Tower of Hanoi\n";
cout << "Enter choice: ";
cin >> choice;

cout << "Enter value of n: ";


cin >> n;

if (choice == 1) {
cout << "Fibonacci Recursive: " << fibonacci(n) << endl;
cout << "Fibonacci Closed-form: " << fibonacciClosed(n) << endl;
} else if (choice == 2) {
cout << "Hanoi Recursive: " << towerOfHanoi(n) << endl;
cout << "Hanoi Closed-form: " << towerOfHanoiClosed(n) << endl;
} else {
cout << "Invalid choice." << endl;
}

return 0;
}

Marks Obtained Total Marks

Instructor Signatures:

Remarks:
FINAL EVALUTION LAB 13

Student Name:

Registration Number:

Date:

Marks Obtained Total Marks

Instructor Signatures:

Remarks:
The University of Lahore Department of Technology

Laboratory Work Assessment Rubrics


Sr. Performance
Excellent (5) Good (4) Average (3) Fair (2) Poor (1)
No. Indicator
Student knows very
Student knows all Student knows most
Student knows few of little about the Student has poor
the related of the related
the related concepts related concepts understanding of the
concepts about the concepts about the
about the theoretical about the related concepts about
theoretical theoretical
Theoretical background of the theoretical the theoretical
background of the background of the
1 knowledge experiment and background of the background of the
experiment and experiment and
10% partially rephrase experiment and experiment and unable
rephrase those partially rephrase
those concepts in poorly rephrase to rephrase those
concepts in written those concepts in
written and oral those concepts in concepts in written
and oral written and oral
assessments written and oral and oral assessments
assessments assessments
assessments
Application Application Application does
Application compiles with few compiles and not compile or
Application runs
compiles with no or no warnings. runs without compiles but
Application smoothly and
warnings. Robust Consideration crashing. Some crashes.
2 Functionality operation of the
operation of the given to unusual attempt at Confusing. Little
10% application runs
application, with conditions with detecting and or no error
efficiently
good recovery. reasonable correcting detection or
recovery errors. correction.
The program works
The program
and produces the The program
works very
The program works correct results and produces correct The program is
Specifications efficiently and
3 and meets some of displays them results but does not producing incorrect
10% meets all of the
the specifications. correctly. It also display them results.
required
meets most of the correctly.
specifications.
other specifications.
Provide complete Provide complete Provide partially
Level of and logical and logical answers correct and logical Provide very few
understanding answers based based upon accurate answers based upon and illogical Provide no answer to

4 of the learned upon accurate technical content to minimum technical answers to the the questions asked by
skill technical content the questions asked content to the questions asked by examiner.

10% to the questions by examiner with questions asked by examiner.


asked by examiner few errors examiner
The code is fairly
The code is Some parts of the The code is poorly
Readability easy to read. The
exceptionally well Most of the code code require organized and very
and code could be reused
5 organized and could be reused in change before they difficult to read and
Reusability as a whole or each
very easy to other programs. could be reused in not organized for
10% class could be
follow and reused other programs. reusability.
reused.
The University of Lahore Department of Technology

Some attempt at
Little attempt at
Well-designed Good data layering data. Some Very poor attempt and
layering data.
Object classes with good abstraction and some generalization of missing code. Code is
Missing, duplicate
Oriented data abstraction data layering. Good interface evident but maintenance
6 or not useful class
Design and layering. Code set of operations missed opportunity. headache. No OOP
interface. Some
10% is highly provided. Little Code can be language feature is
OOP language
maintainable duplications maintained with used
feature is used
significant effort
1. Responds well,
quick and very
1. Generally
accurate all the 1. Not much
Responsive and 1. Generally 1. Non-Responsive
time. Responsive and
accurate most of the Responsive and and inaccurate all the
Responsiveness 2. Effectively uses accurate most of
times. accurate few times. times.
to Questions/ eye contact, the times.
7 2. Maintains eye 2. Some eye contact, 2. No eye contact and
Accuracy speaks clearly, 2. Uses eye contact
contact, speaks speaks clearly and unable to speak
10% effectively and ineffectively and
clearly with suitable unclearly in different 3. Dresses
confidently using fails to speak
volume and pace. portions. inappropriately
suitable volume clearly and audibly
and pace.

Some part of the code


The code is The code is fairly
is efficient and other
extremely efficient efficient without The code is brute The code is huge and
Efficiency part of the code is not
8 without sacrificing sacrificing force and appears to be patched
10% understandable and
readability and readability and unnecessarily long together
work properly
understanding understanding

The code was


The program was The program was The program was The code was
Delivery delivered within a
9 delivered in time delivered in Lab delivered within the delivered more than 2
10% day after the due
during lab. before the end time. due date. days overdue.
date.
Student has
Student has Student has little Student has little
sufficient Student has no
sufficient knowledge knowledge of the knowledge of the
Awareness of knowledge of the knowledge of the
of the laboratory laboratory safety laboratory safety
Safety laboratory safety laboratory safety
10 safety SOPs and SOPs and protocol SOPs and protocol
Guidelines SOPs and protocol SOPs and protocol
protocol and is and is Partially and is non-
10% and is fully and is non-compliant
Partially compliant compliant to the compliant to the
compliant to the to the guidelines
to the guidelines guidelines guidelines
guidelines
Lab No. 14
Open Ended Lab

Objective :
he goal of this lab manual is to understand and implement different concepts of
discrete structures i in C++. By solving various tasks, students will learn how
simplifies complex problems and when to use it effectively.
Tools:
Dev C++
Exercise 1:

Lab Tasks:

Part 1: Basic Implementation

Sorting:

1. Implement the given sorting algorithms for an integer array.


2. Test each algorithm on:

⚫ Sorted input (best case for most algorithms).


⚫ Reverse sorted input (worst case for some algorithms).
⚫ Random input.

3. Measure execution time for small and large arrays.

Solution:
Marks Obtained Total Marks

Instructor Signatures:

Remarks:
FINAL EVALUTION LAB 14

Student Name:

Registration Number:

Date:

Marks Obtained Total Marks

Instructor Signatures:

Remarks:
The University of Lahore Department of Technology

Laboratory Work Assessment Rubrics


Sr. Performance
Excellent (5) Good (4) Average (3) Fair (2) Poor (1)
No. Indicator
Student knows very
Student knows all Student knows most
Student knows few of little about the Student has poor
the related of the related
the related concepts related concepts understanding of the
concepts about the concepts about the
about the theoretical about the related concepts about
theoretical theoretical
Theoretical background of the theoretical the theoretical
background of the background of the
1 knowledge experiment and background of the background of the
experiment and experiment and
10% partially rephrase experiment and experiment and unable
rephrase those partially rephrase
those concepts in poorly rephrase to rephrase those
concepts in written those concepts in
written and oral those concepts in concepts in written
and oral written and oral
assessments written and oral and oral assessments
assessments assessments
assessments
Application Application Application does
Application compiles with few compiles and not compile or
Application runs
compiles with no or no warnings. runs without compiles but
Application smoothly and
warnings. Robust Consideration crashing. Some crashes.
2 Functionality operation of the
operation of the given to unusual attempt at Confusing. Little
10% application runs
application, with conditions with detecting and or no error
efficiently
good recovery. reasonable correcting detection or
recovery errors. correction.
The program works
The program
and produces the The program
works very
The program works correct results and produces correct The program is
Specifications efficiently and
3 and meets some of displays them results but does not producing incorrect
10% meets all of the
the specifications. correctly. It also display them results.
required
meets most of the correctly.
specifications.
other specifications.
Provide complete Provide complete Provide partially
Level of and logical and logical answers correct and logical Provide very few
understanding answers based based upon accurate answers based upon and illogical Provide no answer to

4 of the learned upon accurate technical content to minimum technical answers to the the questions asked by
skill technical content the questions asked content to the questions asked by examiner.

10% to the questions by examiner with questions asked by examiner.


asked by examiner few errors examiner
The code is fairly
The code is Some parts of the The code is poorly
Readability easy to read. The
exceptionally well Most of the code code require organized and very
and code could be reused
5 organized and could be reused in change before they difficult to read and
Reusability as a whole or each
very easy to other programs. could be reused in not organized for
10% class could be
follow and reused other programs. reusability.
reused.
The University of Lahore Department of Technology

Some attempt at
Little attempt at
Well-designed Good data layering data. Some Very poor attempt and
layering data.
Object classes with good abstraction and some generalization of missing code. Code is
Missing, duplicate
Oriented data abstraction data layering. Good interface evident but maintenance
6 or not useful class
Design and layering. Code set of operations missed opportunity. headache. No OOP
interface. Some
10% is highly provided. Little Code can be language feature is
OOP language
maintainable duplications maintained with used
feature is used
significant effort
1. Responds well,
quick and very
1. Generally
accurate all the 1. Not much
Responsive and 1. Generally 1. Non-Responsive
time. Responsive and
accurate most of the Responsive and and inaccurate all the
Responsiveness 2. Effectively uses accurate most of
times. accurate few times. times.
to Questions/ eye contact, the times.
7 2. Maintains eye 2. Some eye contact, 2. No eye contact and
Accuracy speaks clearly, 2. Uses eye contact
contact, speaks speaks clearly and unable to speak
10% effectively and ineffectively and
clearly with suitable unclearly in different 3. Dresses
confidently using fails to speak
volume and pace. portions. inappropriately
suitable volume clearly and audibly
and pace.

Some part of the code


The code is The code is fairly
is efficient and other
extremely efficient efficient without The code is brute The code is huge and
Efficiency part of the code is not
8 without sacrificing sacrificing force and appears to be patched
10% understandable and
readability and readability and unnecessarily long together
work properly
understanding understanding

The code was


The program was The program was The program was The code was
Delivery delivered within a
9 delivered in time delivered in Lab delivered within the delivered more than 2
10% day after the due
during lab. before the end time. due date. days overdue.
date.
Student has
Student has Student has little Student has little
sufficient Student has no
sufficient knowledge knowledge of the knowledge of the
Awareness of knowledge of the knowledge of the
of the laboratory laboratory safety laboratory safety
Safety laboratory safety laboratory safety
10 safety SOPs and SOPs and protocol SOPs and protocol
Guidelines SOPs and protocol SOPs and protocol
protocol and is and is Partially and is non-
10% and is fully and is non-compliant
Partially compliant compliant to the compliant to the
compliant to the to the guidelines
to the guidelines guidelines guidelines
guidelines

You might also like