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

Programming Fundamentals 2020 Workbook

The document is a lab manual titled 'Programming Fundamentals' for a course in Electrical Engineering at The University of Lahore, revised in March 2020. It includes a certificate of approval, a table of contents outlining various programming topics, and a mapping of course learning outcomes with program learning outcomes. Additionally, it provides rubrics for evaluating student performance in lab activities and exercises related to programming concepts.

Uploaded by

burhannajeeb8
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)
7 views

Programming Fundamentals 2020 Workbook

The document is a lab manual titled 'Programming Fundamentals' for a course in Electrical Engineering at The University of Lahore, revised in March 2020. It includes a certificate of approval, a table of contents outlining various programming topics, and a mapping of course learning outcomes with program learning outcomes. Additionally, it provides rubrics for evaluating student performance in lab activities and exercises related to programming concepts.

Uploaded by

burhannajeeb8
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/ 106

PROGRAMMING FUNDAMENTALS

(CS02118)
WORK BOOK

Revised Date

March 2020

NAME M.BURHAN NAJEEB


REG NO BSEE-02183108
SECTION A

DEPARTMENT OF ELECTRICAL ENGINEERING


THE UNIVERSITY OF LAHORE
CERTIFICATE OF APPROVAL

It is certified that the lab manual titled “Programming Fundamentals”, in scope and in quality,
covers the objectives and topics defined in the course outline.

Remarks by Mentor: ----------------------------------------------


Nabeel Shahzad
Assistant Professor
Department of Electrical Engineering
The University of Lahore

Remarks by HOD: -------------------------------------------------


Colonel Salamat-Ullah
Head of Department
Department of Electrical Engineering
The University of Lahore
TABLE OF CONTENTS

1 INTRODUCTION TO COMPILER ................................................................................................................ 7


1.1 PROCEDURES............................................................................................................................................. 7
1.2 OBSERVATION AND RESULTS ......................................................................................................................... 7
1.3 LEARNING OUTCOMES ................................................................................................................................. 7
1.4 EXERCISE QUESTIONS .................................................................................................................................. 8
2 INTRODUCTION TO PROGRAMMING ..................................................................................................... 11
2.1 PROCEDURES........................................................................................................................................... 11
2.2 OBSERVATION AND RESULTS ....................................................................................................................... 11
2.3 LEARNING OUTCOMES ............................................................................................................................... 11
2.4 EXERCISE QUESTIONS ................................................................................................................................ 12
3 SELECTION STATEMENTS/DECISIONS (IF/ELSE & SWITCH) ..................................................................... 16
3.1 PROCEDURES........................................................................................................................................... 16
3.2 OBSERVATION AND RESULTS ....................................................................................................................... 16
3.3 LEARNING OUTCOMES ............................................................................................................................... 16
3.4 EXERCISE QUESTIONS ................................................................................................................................ 17
4 SELECTION STATEMENTS / DECISIONS (SWITCH) ................................................................................... 23
4.1 PROCEDURES........................................................................................................................................... 23
4.2 OBSERVATION AND RESULTS ....................................................................................................................... 23
4.3 LEARNING OUTCOMES ............................................................................................................................... 24
4.4 EXERCISE QUESTIONS ................................................................................................................................ 24
5 REPETITION STRUCTURES / (WHILE AND DO-WHILE LOOP) ................................................................... 29
5.1 PROCEDURES........................................................................................................................................... 29
5.2 OBSERVATION AND RESULTS ....................................................................................................................... 29
5.3 LEARNING OUTCOMES ............................................................................................................................... 29
5.4 EXERCISE QUESTIONS ................................................................................................................................ 30
6 REPETITION STRUCTURES / LOOPS (FOR LOOP) ..................................................................................... 36
6.1 PROCEDURES........................................................................................................................................... 36
6.2 OBSERVATION AND RESULTS ....................................................................................................................... 36
6.3 LEARNING OUTCOMES ............................................................................................................................... 36
6.4 EXERCISE QUESTIONS ................................................................................................................................ 37
7 FUNCTIONS (CALL BY VALUE)................................................................................................................. 43
7.1 PROCEDURES........................................................................................................................................... 43
7.2 OBSERVATION AND RESULTS ....................................................................................................................... 43
7.3 LEARNING OUTCOMES ............................................................................................................................... 43
7.4 EXERCISE QUESTIONS ................................................................................................................................ 44
8 FUNCTIONS (CALL BY REFERENCE) ......................................................................................................... 51
8.1 PROCEDURES........................................................................................................................................... 51
8.2 OBSERVATION AND RESULTS ....................................................................................................................... 51
8.3 LEARNING OUTCOMES ............................................................................................................................... 52
8.4 EXERCISE QUESTIONS ................................................................................................................................ 52
9 DESIGN OF ATM MODEL (OPEN-ENDED LAB) ......................................................................................... 58
9.1 PROCEDURES........................................................................................................................................... 58
9.2 OBSERVATION AND RESULTS ....................................................................................................................... 58
9.3 LEARNING OUTCOMES ............................................................................................................................... 58
9.4 EXERCISE QUESTIONS ................................................................................................................................ 59
10 ARRAYS ................................................................................................................................................. 65
10.1 PROCEDURES........................................................................................................................................... 65
10.2 OBSERVATION AND RESULTS ....................................................................................................................... 65
10.3 LEARNING OUTCOMES ............................................................................................................................... 65
10.4 EXERCISE QUESTIONS ................................................................................................................................ 66
11 2D ARRAYS ............................................................................................................................................ 73
11.1 PROCEDURES........................................................................................................................................... 73
11.2 OBSERVATION AND RESULTS ....................................................................................................................... 73
11.3 LEARNING OUTCOMES ............................................................................................................................... 73
11.4 EXERCISE QUESTIONS ................................................................................................................................ 74
12 STRINGS ................................................................................................................................................ 82
12.1 PROCEDURES........................................................................................................................................... 82
12.2 OBSERVATION AND RESULTS ....................................................................................................................... 82
12.3 LEARNING OUTCOMES ............................................................................................................................... 82
12.4 EXERCISE QUESTIONS ................................................................................................................................ 83
13 POINTERS ........................................................................................... ERROR! BOOKMARK NOT DEFINED.
13.1 PROCEDURES............................................................................................... ERROR! BOOKMARK NOT DEFINED.
13.2 OBSERVATION AND RESULTS ........................................................................... ERROR! BOOKMARK NOT DEFINED.
13.3 LEARNING OUTCOMES ................................................................................... ERROR! BOOKMARK NOT DEFINED.
13.4 EXERCISE QUESTIONS .................................................................................... ERROR! BOOKMARK NOT DEFINED.
14 STRUCTURES AND UNIONS .................................................................................................................... 89
14.1 PROCEDURES........................................................................................................................................... 89
14.2 OBSERVATION AND RESULTS ....................................................................................................................... 89
14.3 LEARNING OUTCOMES ............................................................................................................................... 90
14.4 EXERCISE QUESTIONS ................................................................................................................................ 90
15 FILE HANDLING ................................................................................... ERROR! BOOKMARK NOT DEFINED.
15.1 PROCEDURES............................................................................................... ERROR! BOOKMARK NOT DEFINED.
15.2 OBSERVATION AND RESULTS ........................................................................... ERROR! BOOKMARK NOT DEFINED.
15.3 LEARNING OUTCOMES ................................................................................... ERROR! BOOKMARK NOT DEFINED.
15.4 EXERCISE QUESTIONS .................................................................................... ERROR! BOOKMARK NOT DEFINED.
16 BANKING SCENARIO (OPEN-ENDED LAB) ............................................................................................... 99
16.1 PROCEDURES........................................................................................................................................... 99
16.2 OBSERVATION AND RESULTS ....................................................................................................................... 99
16.3 LEARNING OUTCOMES ............................................................................................................................... 99
16.4 EXERCISE QUESTIONS .............................................................................................................................. 100
MAPPING OF COURSE LEARNING OUTCOMES WITH PLO’S & BLOOM’S LEVEL

Taxonomy Mapped
CLO # CLO Description Domain
Level PLO

Design and Implement the solution of problem


CLO1 using condition, loops, array, functions, Cognitive 6 PLO3
structures and file handling

Apply programing concepts to dry run and


CLO2 Cognitive 3 PLO1
troubleshoot programming problems

Assess societal, health, safety, legal and cultural


CLO3 issues while designing solutions of complex
Cognitive 5 PLO6
engineering problems using modern
Programming techniques.

Develop Computer programs in lab for hands on


CLO4 Cognitive 6 PLO3
experience for students using C++ language.

Behave according to professional ethics and


CLO5 responsibilities with fellow students, lab staff Affective 3 PLO8
and instructor during lab time

Exemplify working efficiently in a group and


CLO6 Affective 5 PLO9
contributing in the lab tasks
MAPPING OF LAB EXPERIMENTS WITH CLO’S, PLO’S & BLOOM’S LEVEL
Sr. Bloom’s
Experiments CLO PLO
No. Level

1 Introduction to Compiler CLO 4,5,6 PLO 3,8,9 C3, A3, A5

2 Introduction to Programming CLO 4,5,6 PLO 3,8,9 C3, A3, A5

3 Selection Statements / Decisions (Switch) CLO 4,5,6 PLO 3,8,9 C3, A3, A5

4 Selection Statements / Decisions (If / Else) CLO 4,5,6 PLO 3,8,9 C3, A3, A5

5 Repetition Structures / Loops (For loop) CLO 4,5,6 PLO 3,8,9 C3, A3, A5

Repetition Structures / Loops (While and Do-


6 CLO 4,5,6 PLO 3,8,9 C3, A3, A5
While loop)

7 Functions (Call by value) CLO 4,5,6 PLO 3,8,9 C3, A3, A5

8 Functions (Call by reference) CLO 4,5,6 PLO 3,8,9 C3, A3, A5

9 Design of ATM Model (Open-Ended Lab) CLO 4,5,6 PLO 3,8,9 C3, A3, A5

10 Arrays CLO 4,5,6 PLO 3,8,9 C3, A3, A5

11 2D Arrays CLO 4,5,6 PLO 3,8,9 C3, A3, A5

12 Strings CLO 4,5,6 PLO 3,8,9 C3, A3, A5

13 Pointers CLO 4,5,6 PLO 3,8,9 C3, A3, A5

14 Structures and Unions CLO 4,5,6 PLO 3,8,9 C3, A3, A5

15 File Handling CLO 4,5,6 PLO 3,8,9 C3, A3, A5

16 Banking transaction scenario (Open-Ended Lab) CLO 4,5,6 PLO 3,8,9 C3, A3, A5
1 INTRODUCTION TO COMPILER

1.1 PROCEDURES

• A compiler is a program that translates the source code for another program from
a programing language into executable code

• Open code block software from your computer

• Write any desired code for compiling.

• Make sure your code is accurate as you know that c language is k sensitive that’s why

Make sure your code is correct

• Now run the program you will see a black window in which your output is visible
• Do it as many times for your own practice

1.2 OBSERVATION AND RESULTS

Before making the program, you must have some basic knowledge of the C++ language
and also, be careful while making a program.

1.3 LEARNING OUTCOMES

With the help of this lab I am able to construct a program,


1.4 EXERCISE QUESTIONS

1.4.1 Which application did you use to create the program?

For compiling I use code block software.

1.4.2 Which compiler did you opt for?

We use code block for programing.

1.4.3 How you can add a new C++ Source file to the active project.

To add the new file to the project, bring up the file template wizard through either File
New File or Main Toolbar New file .File. Select C/C++ source and click Go. Continue
through the following dialogs very much like the original project creation, selecting C++
when prompted for a language.
GENERALIZED LAB RUBRICS

Component with Above Meeting Approaching Below Weight / Score


Used
Taxonomy Expectation (4) Expectation (3) Expectation (2) Expectation (1) 100 (1–4)
Is able to build a Is able to assemble a Is only able to Is not able to
given setup neatly given setup using copy a given assemble a given
and timely using correct hardware setup using setup using
correct hardware components after correct hardware correct hardware
Building
components and / minor revisions components components ☐
(Hardware) – P4
or can reorganize /
adapt to new /
special
requirements
Recording Is able to record Is able to record Is only able to Is unable to
Measurements accurate accurate record accurate record accurate

(Hardware / measurements all measurements most measurements on measurements
Software) – C3 the time of the time some occasions
Is able to Is able to Is not able to Is unable to
formulate/develop evaluate/conclude evaluate/conclude comprehend
theories in correctly about correctly about investigation
addition to investigation investigation parameters
Investigation
evaluating/conclu parameters by parameters by
(Hardware / ☐
ding correctly assessing data assessing data
Software) – C5
about
investigation
parameters by
assessing data
Design / Is able to design / Is able to design / Is able to Is unable to
Development of develop the develop the solution partially design / partially design /
Solution solution of a given of a given problem develop the develop the ☐
(Hardware / problem and add solution of a solution of a
Software) – C6 features to it given problem given problem
Is adept in the use Is able to use the Is able to use the Is unable to use
of software tool software tool software tool but the software tool
Software Usage
and can access effectively by cannot access all ☐
(Software) – C3
advanced features accessing all the the required
required features features
Is able to Is able to complete a Is able to Is unable to
efficiently given task using partially partially
complete a given required complete a given complete a given
task using programming task task
Programming advanced language constructs
Language programming / methods /

(Software) – C3– language commands
C6 constructs /
methods /
commands and/or
add features to the
original task

Additional Comments (if any):

----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
GENERALIZED LAB RUBRICS

Component with Above Meeting Expectation Approaching Below Weight Score


Used
Taxonomy Expectation (4) (3) Expectation (2) Expectation (1) / 100 (1–4)
Assesses and Assesses and
Safety Assesses and Assesses and
complies with complies with
Instructions complies with all complies with most
some EHS few EHS ☐
(PLO6) EHS instructions EHS instructions
instructions while instructions in
A4 while in lab while in lab
in lab lab
Does not
exhibit
Makes an effort to
Exhibits exemplary professional
Exhibits professional exhibit
Professional professional ethics ethics while
ethics while dealing professional ethics
Ethics while dealing with dealing with
with fellow students, while dealing with ☐
(PLO8) fellow students, lab fellow
lab staff and fellow students, lab
A3 staff and instructor students, lab
instructor all the time staff and instructor
all the time staff and
all the time
instructor all
the time
Consistently shows Shows some
full preparation by Consistently shows preparation which Shows very
completing all full preparation by is mostly at little or no
Contribution
agreed tasks and completing all agreed superficial level in preparation in
(PLO9) ☐
provides additional tasks and work completing a task completing a
A5
resources for the requires little or no and work requires task and work
group and work revisions much revisions and quality is poor
quality is excellent editing
Internalized Neither helpful nor
Consistent positive Discouraging
Attitude positive behavior damaging and
behavior most of the behavior
(PLO9) and encourages and shows disinterest in ☐
time towards other towards other
A5 helps other team the performance of
team members team members
members others
Report on all
relevant sections
Report on all Report on all relevant
related to the lab
relevant sections sections related to the
tasks is completed Report on all
related to the lab lab tasks is completed
but many relevant
Report Writing tasks is completed but few deficiencies
deficiencies are sections related
(PLO10) accurately, meeting are present in terms of ☐
present in terms of to the lab tasks
A2 the requirements, accuracy / meeting
accuracy / meeting is not
in prescribed time the requirements /
the requirements / completed
and with good prescribed time / good
prescribed time /
language skills language skills
good language
skills
Manages tasks well Manages tasks within Manages tasks in Does not
Lab Task
within given given timeframe an extended manage tasks
Management
timeframe timeframe even in ☐
(PLO11)
extended
A3
timeframes

Additional Comments (if any):


----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
2 INTRODUCTION TO PROGRAMMING

2.1 PROCEDURES

• Open your code block software on your pc

• Before using C++ language, you must know that this language is k sensitive so that’s why
be careful while using this language
• Now construct a program which is assign to you for practice

• Recheck your program twice so that the chances of mistake can be minimize

• Now run the program

• Your desired output will be displayed on the black window.

2.2 OBSERVATION AND RESULTS

Before making the program, you must have some basic knowledge of the C++ language
and also, be careful while making a program.

2.3 LEARNING OUTCOMES

With the help of this lab I am able to contract different kind of programs.
2.4 EXERCISE QUESTIONS

2.4.1 Differentiate between machine level language and high-level language.

Low level language is machine readable form of program. Whereas the high-level
language will be in human readable form.

2.4.2 Discuss different type of operators and their precedence.

Following are the types of operators:


addition (+)
subtraction (-)
multiplication (*)
The precedence of above operators is that multiplication will come first than addition and then
subtraction.

2.4.3 What type of errors can occur during program development?

There are three kinds of errors: syntax errors, runtime errors, and logic errors.
Syntax error:
A syntax error is an error in the source code of a program.
Runtime errors:
A runtime error is a program error that occurs while the program is running.
logic errors:
A logic error is an error in the program
2.4.4 Write a program to print your introduction in output window.

Code Output

Name: BURHAN
#include<iostream>
NAJEEB
using namespace std;
Reg No: BSEE-
int main() 02183108

{ Location: LAHORE

cout << "Name: BURHAN NAJEEB "<<endl;


Process returned 0 (0x0)
cout << "Reg No: BSEE-02183108 "<<endl;
execution time : 0.017 s
cout << "Location: LAHORE "<<endl; Press any key to

return 0; continue.

}
GENERALIZED LAB RUBRICS

Component with Above Meeting Approaching Below Weight / Score


Used
Taxonomy Expectation (4) Expectation (3) Expectation (2) Expectation (1) 100 (1–4)
Is able to build a Is able to assemble a Is only able to Is not able to
given setup neatly given setup using copy a given assemble a given
and timely using correct hardware setup using setup using
correct hardware components after correct hardware correct hardware
Building
components and / minor revisions components components ☐
(Hardware) – P4
or can reorganize /
adapt to new /
special
requirements
Recording Is able to record Is able to record Is only able to Is unable to
Measurements accurate accurate record accurate record accurate

(Hardware / measurements all measurements most measurements on measurements
Software) – C3 the time of the time some occasions
Is able to Is able to Is not able to Is unable to
formulate/develop evaluate/conclude evaluate/conclude comprehend
theories in correctly about correctly about investigation
addition to investigation investigation parameters
Investigation
evaluating/conclu parameters by parameters by
(Hardware / ☐
ding correctly assessing data assessing data
Software) – C5
about
investigation
parameters by
assessing data
Design / Is able to design / Is able to design / Is able to Is unable to
Development of develop the develop the solution partially design / partially design /
Solution solution of a given of a given problem develop the develop the ☐
(Hardware / problem and add solution of a solution of a
Software) – C6 features to it given problem given problem
Is adept in the use Is able to use the Is able to use the Is unable to use
of software tool software tool software tool but the software tool
Software Usage
and can access effectively by cannot access all ☐
(Software) – C3
advanced features accessing all the the required
required features features
Is able to Is able to complete a Is able to Is unable to
efficiently given task using partially partially
complete a given required complete a given complete a given
task using programming task task
Programming advanced language constructs
Language programming / methods /

(Software) – C3– language commands
C6 constructs /
methods /
commands and/or
add features to the
original task

Additional Comments (if any):

----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
GENERALIZED LAB RUBRICS

Component with Above Meeting Approaching Below Weight / Score


Used
Taxonomy Expectation (4) Expectation (3) Expectation (2) Expectation (1) 100 (1–4)
Is able to build a Is able to assemble a Is only able to Is not able to
given setup neatly given setup using copy a given assemble a given
and timely using correct hardware setup using setup using
correct hardware components after correct hardware correct hardware
Building
components and / minor revisions components components ☐
(Hardware) – P4
or can reorganize /
adapt to new /
special
requirements
Recording Is able to record Is able to record Is only able to Is unable to
Measurements accurate accurate record accurate record accurate

(Hardware / measurements all measurements most measurements on measurements
Software) – C3 the time of the time some occasions
Is able to Is able to Is not able to Is unable to
formulate/develop evaluate/conclude evaluate/conclude comprehend
theories in correctly about correctly about investigation
addition to investigation investigation parameters
Investigation
evaluating/conclu parameters by parameters by
(Hardware / ☐
ding correctly assessing data assessing data
Software) – C5
about
investigation
parameters by
assessing data
Design / Is able to design / Is able to design / Is able to Is unable to
Development of develop the develop the solution partially design / partially design /
Solution solution of a given of a given problem develop the develop the ☐
(Hardware / problem and add solution of a solution of a
Software) – C6 features to it given problem given problem
Is adept in the use Is able to use the Is able to use the Is unable to use
of software tool software tool software tool but the software tool
Software Usage
and can access effectively by cannot access all ☐
(Software) – C3
advanced features accessing all the the required
required features features
Is able to Is able to complete a Is able to Is unable to
efficiently given task using partially partially
complete a given required complete a given complete a given
task using programming task task
Programming advanced language constructs
Language programming / methods /

(Software) – C3– language commands
C6 constructs /
methods /
commands and/or
add features to the
original task

Additional Comments (if any):

----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
3 SELECTION STATEMENTS/DECISIONS (IF/ELSE & SWITCH)

3.1 PROCEDURES

• Open your code block software


• Add a new doc

• Write a program which is provided to you for compiling

• Use if else statement carefully


• For your last condition just use else
• The operators should be used properly

• Recheck your program twice and give run command

3.2 OBSERVATION AND RESULTS

Before making the program, you must have some basic knowledge of the C++ language

And also, be careful while making a program.

3.3 LEARNING OUTCOMES

With the help of this program I am able to construct different program using if else statement.
3.4 EXERCISE QUESTIONS

3.4.1 Write a C++ Program in this we are taking a character from keyboard and
checking whether it is Vowel or Consonant, before it we are checking it is valid
alphabet or not?

Write a C++ Program to print positive number entered by the user If user enters negative
number, it is skipped.
Write a program to determine whether a given number is 5-digit number or not. Further
check if it’s a Numeric Palindrome.
GENERALIZED LAB RUBRICS

Component with Above Meeting Approaching Below Weight / Score


Used
Taxonomy Expectation (4) Expectation (3) Expectation (2) Expectation (1) 100 (1–4)
Is able to build a Is able to assemble a Is only able to Is not able to
given setup neatly given setup using copy a given assemble a given
and timely using correct hardware setup using setup using
correct hardware components after correct hardware correct hardware
Building
components and / minor revisions components components ☐
(Hardware) – P4
or can reorganize /
adapt to new /
special
requirements
Recording Is able to record Is able to record Is only able to Is unable to
Measurements accurate accurate record accurate record accurate

(Hardware / measurements all measurements most measurements on measurements
Software) – C3 the time of the time some occasions
Is able to Is able to Is not able to Is unable to
formulate/develop evaluate/conclude evaluate/conclude comprehend
theories in correctly about correctly about investigation
addition to investigation investigation parameters
Investigation
evaluating/conclu parameters by parameters by
(Hardware / ☐
ding correctly assessing data assessing data
Software) – C5
about
investigation
parameters by
assessing data
Design / Is able to design / Is able to design / Is able to Is unable to
Development of develop the develop the solution partially design / partially design /
Solution solution of a given of a given problem develop the develop the ☐
(Hardware / problem and add solution of a solution of a
Software) – C6 features to it given problem given problem
Is adept in the use Is able to use the Is able to use the Is unable to use
of software tool software tool software tool but the software tool
Software Usage
and can access effectively by cannot access all ☐
(Software) – C3
advanced features accessing all the the required
required features features
Is able to Is able to complete a Is able to Is unable to
efficiently given task using partially partially
complete a given required complete a given complete a given
task using programming task task
Programming advanced language constructs
Language programming / methods /

(Software) – C3– language commands
C6 constructs /
methods /
commands and/or
add features to the
original task

Additional Comments (if any):

----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
GENERALIZED LAB RUBRICS

Component with Above Meeting Expectation Approaching Below Weight Score


Used
Taxonomy Expectation (4) (3) Expectation (2) Expectation (1) / 100 (1–4)
Assesses and Assesses and
Safety Assesses and Assesses and
complies with complies with
Instructions complies with all complies with most
some EHS few EHS ☐
(PLO6) EHS instructions EHS instructions
instructions while instructions in
A4 while in lab while in lab
in lab lab
Does not
exhibit
Makes an effort to
Exhibits exemplary professional
Exhibits professional exhibit
Professional professional ethics ethics while
ethics while dealing professional ethics
Ethics while dealing with dealing with
with fellow students, while dealing with ☐
(PLO8) fellow students, lab fellow
lab staff and fellow students, lab
A3 staff and instructor students, lab
instructor all the time staff and instructor
all the time staff and
all the time
instructor all
the time
Consistently shows Shows some
full preparation by Consistently shows preparation which Shows very
completing all full preparation by is mostly at little or no
Contribution
agreed tasks and completing all agreed superficial level in preparation in
(PLO9) ☐
provides additional tasks and work completing a task completing a
A5
resources for the requires little or no and work requires task and work
group and work revisions much revisions and quality is poor
quality is excellent editing
Internalized Neither helpful nor
Consistent positive Discouraging
Attitude positive behavior damaging and
behavior most of the behavior
(PLO9) and encourages and shows disinterest in ☐
time towards other towards other
A5 helps other team the performance of
team members team members
members others
Report on all
relevant sections
Report on all Report on all relevant
related to the lab
relevant sections sections related to the
tasks is completed Report on all
related to the lab lab tasks is completed
but many relevant
Report Writing tasks is completed but few deficiencies
deficiencies are sections related
(PLO10) accurately, meeting are present in terms of ☐
present in terms of to the lab tasks
A2 the requirements, accuracy / meeting
accuracy / meeting is not
in prescribed time the requirements /
the requirements / completed
and with good prescribed time / good
prescribed time /
language skills language skills
good language
skills
Manages tasks well Manages tasks within Manages tasks in Does not
Lab Task
within given given timeframe an extended manage tasks
Management
timeframe timeframe even in ☐
(PLO11)
extended
A3
timeframes

Additional Comments (if any):


----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
4 SELECTION STATEMENTS / DECISIONS (SWITCH)

4.1 PROCEDURES

Switch case statement is used when we have multiple conditions and we need to

perform different action based on the condition. When we have multiple conditions and

we need to execute a block of statements when a particular condition is satisfied. In

such case we can use switch case. Switch Case statement is mostly used with break

statement even though the break statement is optional.

4.2 OBSERVATION AND RESULTS

The expression is evaluated once and compared with the values of each case label.
If there is a match, the corresponding code after the matching label is executed
If there is no match, the code after default: is executed.
4.3 LEARNING OUTCOMES

we learn the use of switch statement if C++ programing and become familiar with the

working of switch statement.

4.4 EXERCISE QUESTIONS

4.4.1 Write a C++ Program to Make a Simple Calculator to Add, Subtract, Multiply
or Divide Using switch...case.

Code Output
#include <iostream> Enter operator either +
or - or * or /: +
using namespace std; Enter two operands: 2
int main() 2
{ 4
char op;
float num1, num2;
cout<< "Enter operator either + or - or * or /: ";
cin>> op;
cout<< "Enter two operands: ";
cin>> num1 >> num2;
switch(op)
{
case '+':
cout<< num1+num2; break;
case '-': cout<< num1-num2;
break;
case '*': cout<< num1*num2; break;
case '/':
cout<< num1/num2; break;
cout<< "Error! operator is not correct"; break;
}
return 0;
}

4.4.2 Write a program that will find the grade of a number given his marks out of
100.

Code Output
#include <iostream> enter the obtain
marks=60
using namespace std; Your Grade Is: C
int main()
{
int marks;
cout<< "enter the obtain marks="<<endl;
cin>>marks;
switch(marks/10)
{case 10:
case 9:
cout<< "\nYour Grade Is: A ";
break;
case 8:
case 7:
cout<< "\nYour Grade Is: B ";
break;
case 6:
cout<< "\nYour Grade Is: C ";
break;
case 5:
case 4:
cout<< "\nYour Grade Is: D or Pass";
break;
default:
cout<< "\nYou Grade Is: F ";}
Return 0;
}

4.4.3 Write a program to find if the given number is even or odd.

Code Output
#include <iostream> Enter any number to
check even or odd:2
using namespace std; Number is even
int main(){
intnum;
cout<<"Enter any number to check even or odd: ";
cin>>num;
switch(num % 2)
{
case 0: cout<<"Number is even";
break;
case 1: cout<<"Number is odd";
break;
}
return 0;
}
GENERALIZED LAB RUBRICS

Component with Above Meeting Approaching Below Weight / Score


Used
Taxonomy Expectation (4) Expectation (3) Expectation (2) Expectation (1) 100 (1–4)
Is able to build a Is able to assemble a Is only able to Is not able to
given setup neatly given setup using copy a given assemble a given
and timely using correct hardware setup using setup using
correct hardware components after correct hardware correct hardware
Building
components and / minor revisions components components ☐
(Hardware) – P4
or can reorganize /
adapt to new /
special
requirements
Recording Is able to record Is able to record Is only able to Is unable to
Measurements accurate accurate record accurate record accurate

(Hardware / measurements all measurements most measurements on measurements
Software) – C3 the time of the time some occasions
Is able to Is able to Is not able to Is unable to
formulate/develop evaluate/conclude evaluate/conclude comprehend
theories in correctly about correctly about investigation
addition to investigation investigation parameters
Investigation
evaluating/conclu parameters by parameters by
(Hardware / ☐
ding correctly assessing data assessing data
Software) – C5
about
investigation
parameters by
assessing data
Design / Is able to design / Is able to design / Is able to Is unable to
Development of develop the develop the solution partially design / partially design /
Solution solution of a given of a given problem develop the develop the ☐
(Hardware / problem and add solution of a solution of a
Software) – C6 features to it given problem given problem
Is adept in the use Is able to use the Is able to use the Is unable to use
of software tool software tool software tool but the software tool
Software Usage
and can access effectively by cannot access all ☐
(Software) – C3
advanced features accessing all the the required
required features features
Is able to Is able to complete a Is able to Is unable to
efficiently given task using partially partially
complete a given required complete a given complete a given
task using programming task task
Programming advanced language constructs
Language programming / methods /

(Software) – C3– language commands
C6 constructs /
methods /
commands and/or
add features to the
original task

Additional Comments (if any):

----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
GENERALIZED LAB RUBRICS

Component with Above Meeting Expectation Approaching Below Weight Score


Used
Taxonomy Expectation (4) (3) Expectation (2) Expectation (1) / 100 (1–4)
Assesses and Assesses and
Safety Assesses and Assesses and
complies with complies with
Instructions complies with all complies with most
some EHS few EHS ☐
(PLO6) EHS instructions EHS instructions
instructions while instructions in
A4 while in lab while in lab
in lab lab
Does not
exhibit
Makes an effort to
Exhibits exemplary professional
Exhibits professional exhibit
Professional professional ethics ethics while
ethics while dealing professional ethics
Ethics while dealing with dealing with
with fellow students, while dealing with ☐
(PLO8) fellow students, lab fellow
lab staff and fellow students, lab
A3 staff and instructor students, lab
instructor all the time staff and instructor
all the time staff and
all the time
instructor all
the time
Consistently shows Shows some
full preparation by Consistently shows preparation which Shows very
completing all full preparation by is mostly at little or no
Contribution
agreed tasks and completing all agreed superficial level in preparation in
(PLO9) ☐
provides additional tasks and work completing a task completing a
A5
resources for the requires little or no and work requires task and work
group and work revisions much revisions and quality is poor
quality is excellent editing
Internalized Neither helpful nor
Consistent positive Discouraging
Attitude positive behavior damaging and
behavior most of the behavior
(PLO9) and encourages and shows disinterest in ☐
time towards other towards other
A5 helps other team the performance of
team members team members
members others
Report on all
relevant sections
Report on all Report on all relevant
related to the lab
relevant sections sections related to the
tasks is completed Report on all
related to the lab lab tasks is completed
but many relevant
Report Writing tasks is completed but few deficiencies
deficiencies are sections related
(PLO10) accurately, meeting are present in terms of ☐
present in terms of to the lab tasks
A2 the requirements, accuracy / meeting
accuracy / meeting is not
in prescribed time the requirements /
the requirements / completed
and with good prescribed time / good
prescribed time /
language skills language skills
good language
skills
Manages tasks well Manages tasks within Manages tasks in Does not
Lab Task
within given given timeframe an extended manage tasks
Management
timeframe timeframe even in ☐
(PLO11)
extended
A3
timeframes

Additional Comments (if any):


----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
5 REPETITION STRUCTURES / (WHILE AND DO-WHILE
LOOP)

5.1 PROCEDURES

• Open your code block software

• Make a new document file

• Write a program which is provided to you for compiling


• Use While and Do-While loop statement carefully

• The operators should be used properly

• Recheck your program twice and give run command

5.2 OBSERVATION AND RESULTS

Before making the program, you must have some basic knowledge of the C++ language

And also, be careful while making a program

5.3 LEARNING OUTCOMES

In this lab I have learned to design different programs using while and do while conditions.
5.4 EXERCISE QUESTIONS

5.4.1 Write a C++ program to find if the given number is a perfect number and find
its all positive divisors excluding that number

Code Output
Enter number to be checked
#include<iostream>
:
using namespace std; 56

int main () 56 is not a perfect number.

int i, num, div, sum=0; Divisors are : 56

{ 1

cout << "Enter number to be checked : "<<endl; 2

cin >> num; 4

7
for (i=1; i < num; i++)

{ 8
div = num % i;

if (div == 0) 14

sum = sum + i;
} 28

if (sum == num)
cout << num <<" is a perfect number."<< endl;

Else
cout << num <<" is not a perfect number."<< endl;

cout << "Divisors are : "<<num<<endl;


for(i=1;i!=num;++i)

{
if(num%i==0)

cout<<i<<endl;
}
return 0;
}
5.4.2 Write a C++ program to make custom countdown timer using while loop.

Code Output
#include <iostream> 68

#include <Windows.h> Time remaining: 61

using namespace std;

int main()

int n;

cin>>n;

Sleep(1000);

while (n >= 1)

cout << "\rTime remaining: " << n << flush;

Sleep(1000);

n--;

5.4.3 Write a C++ program to Generate Fibonacci Sequence Up to a Certain


Number Given by the User.

Code Output

#include <iostream> Enter the number of terms:

using namespace std; 3

int main() Fibonacci Series:


{ 0

int n, num1 = 0, num2 = 1, nextTerm = 0; 1

cout << "Enter the number of terms: "<<endl; 1

cin >> n;

cout << "Fibonacci Series: "<<endl;

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

if(i == 1)

cout<< " " <<num1<<endl;

continue;

if(i == 2)

cout<< " " <<num2<<endl;

continue;

nextTerm = num1 + num2;

num1 = num2;

num2 = nextTerm;

cout<< " " <<nextTerm<<endl;

}
return 0;
}

5.4.4 Write a program that takes input of two integer type variables from user then prints
their LCM (Least Common Multiple).

Code Output

#include <iostream> Enter num 1:

using namespace std; 5

int main() Enter num 2:


{ 8

int no1, no2, max; LCM = 40

cout << "Enter num 1: "<<endl;

cin >> no1;

cout << "Enter num 2: "<<endl;

cin >> no2;

max = (no1 > no2) ? no1 : no2;

do

if (max % no1 == 0 && max % no2 == 0)

cout << "LCM = " << max<<endl;

break;

else

++max;

} while (true);

return 0;

}
GENERALIZED LAB RUBRICS

Component with Above Meeting Approaching Below Weight / Score


Used
Taxonomy Expectation (4) Expectation (3) Expectation (2) Expectation (1) 100 (1–4)
Is able to build a Is able to assemble a Is only able to Is not able to
given setup neatly given setup using copy a given assemble a given
and timely using correct hardware setup using setup using
correct hardware components after correct hardware correct hardware
Building
components and / minor revisions components components ☐
(Hardware) – P4
or can reorganize /
adapt to new /
special
requirements
Recording Is able to record Is able to record Is only able to Is unable to
Measurements accurate accurate record accurate record accurate

(Hardware / measurements all measurements most measurements on measurements
Software) – C3 the time of the time some occasions
Is able to Is able to Is not able to Is unable to
formulate/develop evaluate/conclude evaluate/conclude comprehend
theories in correctly about correctly about investigation
addition to investigation investigation parameters
Investigation
evaluating/conclu parameters by parameters by
(Hardware / ☐
ding correctly assessing data assessing data
Software) – C5
about
investigation
parameters by
assessing data
Design / Is able to design / Is able to design / Is able to Is unable to
Development of develop the develop the solution partially design / partially design /
Solution solution of a given of a given problem develop the develop the ☐
(Hardware / problem and add solution of a solution of a
Software) – C6 features to it given problem given problem
Is adept in the use Is able to use the Is able to use the Is unable to use
of software tool software tool software tool but the software tool
Software Usage
and can access effectively by cannot access all ☐
(Software) – C3
advanced features accessing all the the required
required features features
Is able to Is able to complete a Is able to Is unable to
efficiently given task using partially partially
complete a given required complete a given complete a given
task using programming task task
Programming advanced language constructs
Language programming / methods /

(Software) – C3– language commands
C6 constructs /
methods /
commands and/or
add features to the
original task

Additional Comments (if any):

----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
GENERALIZED LAB RUBRICS

Component with Above Meeting Expectation Approaching Below Weight Score


Used
Taxonomy Expectation (4) (3) Expectation (2) Expectation (1) / 100 (1–4)
Assesses and Assesses and
Safety Assesses and Assesses and
complies with complies with
Instructions complies with all complies with most
some EHS few EHS ☐
(PLO6) EHS instructions EHS instructions
instructions while instructions in
A4 while in lab while in lab
in lab lab
Does not
exhibit
Makes an effort to
Exhibits exemplary professional
Exhibits professional exhibit
Professional professional ethics ethics while
ethics while dealing professional ethics
Ethics while dealing with dealing with
with fellow students, while dealing with ☐
(PLO8) fellow students, lab fellow
lab staff and fellow students, lab
A3 staff and instructor students, lab
instructor all the time staff and instructor
all the time staff and
all the time
instructor all
the time
Consistently shows Shows some
full preparation by Consistently shows preparation which Shows very
completing all full preparation by is mostly at little or no
Contribution
agreed tasks and completing all agreed superficial level in preparation in
(PLO9) ☐
provides additional tasks and work completing a task completing a
A5
resources for the requires little or no and work requires task and work
group and work revisions much revisions and quality is poor
quality is excellent editing
Internalized Neither helpful nor
Consistent positive Discouraging
Attitude positive behavior damaging and
behavior most of the behavior
(PLO9) and encourages and shows disinterest in ☐
time towards other towards other
A5 helps other team the performance of
team members team members
members others
Report on all
relevant sections
Report on all Report on all relevant
related to the lab
relevant sections sections related to the
tasks is completed Report on all
related to the lab lab tasks is completed
but many relevant
Report Writing tasks is completed but few deficiencies
deficiencies are sections related
(PLO10) accurately, meeting are present in terms of ☐
present in terms of to the lab tasks
A2 the requirements, accuracy / meeting
accuracy / meeting is not
in prescribed time the requirements /
the requirements / completed
and with good prescribed time / good
prescribed time /
language skills language skills
good language
skills
Manages tasks well Manages tasks within Manages tasks in Does not
Lab Task
within given given timeframe an extended manage tasks
Management
timeframe timeframe even in ☐
(PLO11)
extended
A3
timeframes

Additional Comments (if any):


----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
6 REPETITION STRUCTURES / LOOPS (FOR LOOP)

6.1 PROCEDURES

• Open your code block software


• Make a new document file

• Write a program which is provided to you for compiling

• Use loops and for loop statement carefully


• The operators should be used properly
• Recheck your program twice and give run command

6.2 OBSERVATION AND RESULTS

Before making the program, you must have some basic knowledge of the C++ language

And also, be careful while making a program

6.3 LEARNING OUTCOMES

In this lab I have learned to design different programs using loops and for loop conditions.
6.4 EXERCISE QUESTIONS

6.4.1 A program that gets starting and ending point from the user and displays all
odd numbers in the given range.

Code Output

#include <iostream> Enter the min range:

using namespace std; 3

int main() Enter the max range:

{ 12

Odd numbers in given


int num;
range are:
int min,max; 3

cout << "Enter the min range: "<<endl; 5

cin >> min; 7

cout << "Enter the max range: "<<endl; 9

cin >> max; 11

cout << "Odd numbers in given range are: "<<endl;

for(num = min;num <= max; num++)

if(num % 2 !=0)

cout << num <<endl;

return 0;

}
6.4.2 Program that takes input of an integer type variable from user then calculates
and prints its factorial.

Code Output
#include<iostream> Enter Number:

using namespace std; 5

int main() Factorial is: 120

int num,factorial=1;

cout<<"Enter Number: "<<endl;

cin>>num;

for (int a=1;a<=num;a++)

factorial=factorial*a;

cout<<"Factorial is: "<<factorial<<endl;


return 0;
}
6.4.3 Write a program that reads a positive integer then determines and outputs the
largest power of 2 that is less than or equal to the given number.

Code Output
Enter value to find highest
#include<iostream>
power of 2 is:
using namespace std; 34

int highestPowerof2 Highest power of 2 is: 32

(int n)
{
int res = 0;
for (int i=n; i>=1; i--)
{
if ((i & (i-1)) == 0)
{
res = i;
break;
}
}
return res;
}
int main()
{
int n;
cout<<"Enter value to find highest power of 2 is: "<<endl;

cin>> n;
cout <<"Highest power of 2 is: "<<
highestPowerof2(n)<<endl;
return 0;

}
6.4.4 Write a program to print following pattern using Nested Loop.

*****
****
***
**
*
Code Output

#include <iostream> Enter num of rows:

using namespace std; 5

int main() *****

{ ****

int i, j, row; ***

cout << "Enter num of rows: "<<endl; **

cin >> row; *

for(i = row; i >= 1; i--)

for(j = 1; j <= i; j++)


{
cout << "* ";
}
cout << endl;
}
return 0;
}
GENERALIZED LAB RUBRICS

Component with Above Meeting Approaching Below Weight / Score


Used
Taxonomy Expectation (4) Expectation (3) Expectation (2) Expectation (1) 100 (1–4)
Is able to build a Is able to assemble a Is only able to Is not able to
given setup neatly given setup using copy a given assemble a given
and timely using correct hardware setup using setup using
correct hardware components after correct hardware correct hardware
Building
components and / minor revisions components components ☐
(Hardware) – P4
or can reorganize /
adapt to new /
special
requirements
Recording Is able to record Is able to record Is only able to Is unable to
Measurements accurate accurate record accurate record accurate

(Hardware / measurements all measurements most measurements on measurements
Software) – C3 the time of the time some occasions
Is able to Is able to Is not able to Is unable to
formulate/develop evaluate/conclude evaluate/conclude comprehend
theories in correctly about correctly about investigation
addition to investigation investigation parameters
Investigation
evaluating/conclu parameters by parameters by
(Hardware / ☐
ding correctly assessing data assessing data
Software) – C5
about
investigation
parameters by
assessing data
Design / Is able to design / Is able to design / Is able to Is unable to
Development of develop the develop the solution partially design / partially design /
Solution solution of a given of a given problem develop the develop the ☐
(Hardware / problem and add solution of a solution of a
Software) – C6 features to it given problem given problem
Is adept in the use Is able to use the Is able to use the Is unable to use
of software tool software tool software tool but the software tool
Software Usage
and can access effectively by cannot access all ☐
(Software) – C3
advanced features accessing all the the required
required features features
Is able to Is able to complete a Is able to Is unable to
efficiently given task using partially partially
complete a given required complete a given complete a given
task using programming task task
Programming advanced language constructs
Language programming / methods /

(Software) – C3– language commands
C6 constructs /
methods /
commands and/or
add features to the
original task

Additional Comments (if any):

----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
GENERALIZED LAB RUBRICS

Component with Above Meeting Expectation Approaching Below Weight Score


Used
Taxonomy Expectation (4) (3) Expectation (2) Expectation (1) / 100 (1–4)
Assesses and Assesses and
Safety Assesses and Assesses and
complies with complies with
Instructions complies with all complies with most
some EHS few EHS ☐
(PLO6) EHS instructions EHS instructions
instructions while instructions in
A4 while in lab while in lab
in lab lab
Does not
exhibit
Makes an effort to
Exhibits exemplary professional
Exhibits professional exhibit
Professional professional ethics ethics while
ethics while dealing professional ethics
Ethics while dealing with dealing with
with fellow students, while dealing with ☐
(PLO8) fellow students, lab fellow
lab staff and fellow students, lab
A3 staff and instructor students, lab
instructor all the time staff and instructor
all the time staff and
all the time
instructor all
the time
Consistently shows Shows some
full preparation by Consistently shows preparation which Shows very
completing all full preparation by is mostly at little or no
Contribution
agreed tasks and completing all agreed superficial level in preparation in
(PLO9) ☐
provides additional tasks and work completing a task completing a
A5
resources for the requires little or no and work requires task and work
group and work revisions much revisions and quality is poor
quality is excellent editing
Internalized Neither helpful nor
Consistent positive Discouraging
Attitude positive behavior damaging and
behavior most of the behavior
(PLO9) and encourages and shows disinterest in ☐
time towards other towards other
A5 helps other team the performance of
team members team members
members others
Report on all
relevant sections
Report on all Report on all relevant
related to the lab
relevant sections sections related to the
tasks is completed Report on all
related to the lab lab tasks is completed
but many relevant
Report Writing tasks is completed but few deficiencies
deficiencies are sections related
(PLO10) accurately, meeting are present in terms of ☐
present in terms of to the lab tasks
A2 the requirements, accuracy / meeting
accuracy / meeting is not
in prescribed time the requirements /
the requirements / completed
and with good prescribed time / good
prescribed time /
language skills language skills
good language
skills
Manages tasks well Manages tasks within Manages tasks in Does not
Lab Task
within given given timeframe an extended manage tasks
Management
timeframe timeframe even in ☐
(PLO11)
extended
A3
timeframes

Additional Comments (if any):


----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
7 FUNCTIONS (CALL BY VALUE)

7.1 PROCEDURES

• Open your code block software


• Make a new document file

• Write a program which is provided to you for compiling

• The operators should be used properly


• Recheck your program twice and give run command

7.2 OBSERVATION AND RESULTS

Before making the program, you must have some basic knowledge of the C++ language

And also, be careful while making a program

7.3 LEARNING OUTCOMES

In this lab I have learned to design different programs using recursive conditions.
7.4 EXERCISE QUESTIONS

7.4.1 Write a program to find and print Roots of a quadratic equation using pre-
defined functions.

Code Output
Enter coefficients a, b and
#include <iostream>
c:
#include <cmath> 3

using namespace std; 4

int main() 5
{
Roots are complex and
float a, b, c, x1, x2, discriminant, realPart, imaginaryPart;
different.
cout << "Enter coefficients a, b and c: "<<endl; x1 = -0.666667+1.10554i

cin >> a >> b >> c; x2 = -0.666667-1.10554i

discriminant = b*b - 4*a*c;


if (discriminant > 0)
{
x1 = (-b + sqrt(discriminant)) / (2*a);

x2 = (-b - sqrt(discriminant)) / (2*a);

cout << "Roots are real and different." << endl;

cout << "x1 = " << x1 << endl;


cout << "x2 = " << x2 << endl;
}
else if (discriminant == 0)
{
cout << "Roots are real and same." << endl;

x1 = (-b + sqrt(discriminant)) / (2*a);


cout << "x1 = x2 =" << x1 << endl;
}
else
{
realPart = -b/(2*a);
imaginaryPart =sqrt(-discriminant)/(2*a);

cout << "Roots are complex and different." << endl;

cout << "x1 = " << realPart << "+" << imaginaryPart << "i"
<< endl;
cout << "x2 = " << realPart << "-" << imaginaryPart << "i"
<< endl;
}

return 0;
}

7.4.2 Write a program that uses a recursive function to compute factorial of a


number.

Code Output
Enter number to find
#include <iostream>
factorial
using namespace std; 4

int fact(int n) Factorial of 4 is 24

{
if ((n==0)||(n==1))
return 1;
else
return n*fact(n-1);
}
int main()
{
int n;

cout<<"Enter number to find factorial"<<endl;

cin>>n;

cout<<"Factorial of "<<n<<" is "<<fact(n)<<endl;


return 0;
}
7.4.3 Write a program that will change case of given letters and print accordingly
by User-Defined Functions.

Code Output

#include<iostream> Enter the character: a

A is the upper case of given


#include<cctype>
character
using namespace std;
int main()
{
char c;

cout << "Enter the character : ";


cin >> c;

if (!isalpha(c))
cout << c << " is not an alphabetical character." << endl;
else
{
int case_val;
if (c >= 'a' && c <= 'z')
{
c = c - 'a' + 'A';
case_val = 1;
}
else if (c >= 'A' || c <= 'Z')
{
c = c + 'a' - 'A';
case_val = 0;
}
cout << c << " is the " << ( (case_val == 1) ? "upper" :
"lower" )
<< " case of given character " << endl;

}
return 0;
}
7.4.4 Write a recursive function that finds out whether a number is even or odd.
You can’t use % operator. If you subtract 2 repeatedly from a number then
finally the number will be reduced to 0 or 1 that would be base case for
recursive call

Code Output
#include <iostream> Enter a number to find odd
or even
#include <conio.h> 7

using namespace std; It is a odd number

int isEven(int);

int main()
{
int num;

cout << "Enter a number to find odd or even" << endl;


cin>>num;

if(isEven(num))
{
cout<<"It is a even number";
}
else{

cout<<"It is a odd number";


}
cout<<endl;

getch();

return 0;
}
int isEven(int num)
{
if(num==0)
{
return 1;
}
else if(num==1)
{
return 0;
}
else if(num<0)
{
return isEven(-num);
}
Else
return isEven(num-2);
}
GENERALIZED LAB RUBRICS

Component with Above Meeting Approaching Below Weight / Score


Used
Taxonomy Expectation (4) Expectation (3) Expectation (2) Expectation (1) 100 (1–4)
Is able to build a Is able to assemble a Is only able to Is not able to
given setup neatly given setup using copy a given assemble a given
and timely using correct hardware setup using setup using
correct hardware components after correct hardware correct hardware
Building
components and / minor revisions components components ☐
(Hardware) – P4
or can reorganize /
adapt to new /
special
requirements
Recording Is able to record Is able to record Is only able to Is unable to
Measurements accurate accurate record accurate record accurate

(Hardware / measurements all measurements most measurements on measurements
Software) – C3 the time of the time some occasions
Is able to Is able to Is not able to Is unable to
formulate/develop evaluate/conclude evaluate/conclude comprehend
theories in correctly about correctly about investigation
addition to investigation investigation parameters
Investigation
evaluating/conclu parameters by parameters by
(Hardware / ☐
ding correctly assessing data assessing data
Software) – C5
about
investigation
parameters by
assessing data
Design / Is able to design / Is able to design / Is able to Is unable to
Development of develop the develop the solution partially design / partially design /
Solution solution of a given of a given problem develop the develop the ☐
(Hardware / problem and add solution of a solution of a
Software) – C6 features to it given problem given problem
Is adept in the use Is able to use the Is able to use the Is unable to use
of software tool software tool software tool but the software tool
Software Usage
and can access effectively by cannot access all ☐
(Software) – C3
advanced features accessing all the the required
required features features
Is able to Is able to complete a Is able to Is unable to
efficiently given task using partially partially
complete a given required complete a given complete a given
task using programming task task
Programming advanced language constructs
Language programming / methods /

(Software) – C3– language commands
C6 constructs /
methods /
commands and/or
add features to the
original task

Additional Comments (if any):

----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
GENERALIZED LAB RUBRICS

Component with Above Meeting Expectation Approaching Below Weight Score


Used
Taxonomy Expectation (4) (3) Expectation (2) Expectation (1) / 100 (1–4)
Assesses and Assesses and
Safety Assesses and Assesses and
complies with complies with
Instructions complies with all complies with most
some EHS few EHS ☐
(PLO6) EHS instructions EHS instructions
instructions while instructions in
A4 while in lab while in lab
in lab lab
Does not
exhibit
Makes an effort to
Exhibits exemplary professional
Exhibits professional exhibit
Professional professional ethics ethics while
ethics while dealing professional ethics
Ethics while dealing with dealing with
with fellow students, while dealing with ☐
(PLO8) fellow students, lab fellow
lab staff and fellow students, lab
A3 staff and instructor students, lab
instructor all the time staff and instructor
all the time staff and
all the time
instructor all
the time
Consistently shows Shows some
full preparation by Consistently shows preparation which Shows very
completing all full preparation by is mostly at little or no
Contribution
agreed tasks and completing all agreed superficial level in preparation in
(PLO9) ☐
provides additional tasks and work completing a task completing a
A5
resources for the requires little or no and work requires task and work
group and work revisions much revisions and quality is poor
quality is excellent editing
Internalized Neither helpful nor
Consistent positive Discouraging
Attitude positive behavior damaging and
behavior most of the behavior
(PLO9) and encourages and shows disinterest in ☐
time towards other towards other
A5 helps other team the performance of
team members team members
members others
Report on all
relevant sections
Report on all Report on all relevant
related to the lab
relevant sections sections related to the
tasks is completed Report on all
related to the lab lab tasks is completed
but many relevant
Report Writing tasks is completed but few deficiencies
deficiencies are sections related
(PLO10) accurately, meeting are present in terms of ☐
present in terms of to the lab tasks
A2 the requirements, accuracy / meeting
accuracy / meeting is not
in prescribed time the requirements /
the requirements / completed
and with good prescribed time / good
prescribed time /
language skills language skills
good language
skills
Manages tasks well Manages tasks within Manages tasks in Does not
Lab Task
within given given timeframe an extended manage tasks
Management
timeframe timeframe even in ☐
(PLO11)
extended
A3
timeframes

Additional Comments (if any):


----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
8 FUNCTIONS (CALL BY REFERENCE)

8.1 PROCEDURES

The call by reference method of passing arguments to a function copies the reference of an

argument into the formal parameter. Inside the function, the reference is used to

access the actual argument used in the call. This means that changes made to the

parameter affect the past argument.

To pass the value by reference, argument reference is passed to the functions just like

any other value. So accordingly, you need to declare the function parameters as reference

types as in the following function swap (), which exchanges the values of the two integers

variables pointed to by its arguments.

8.2 OBSERVATION AND RESULTS

In call by reference, the operation performed on formal parameters, affects the value

of actual parameters because all the operations performed on the value stored in the

address of actual parameters.


8.3 LEARNING OUTCOMES

In this lab we learned about functions (call by reference) and become familiar with the
properties

And use to functions in programming.

8.4 EXERCISE QUESTIONS

8.4.1 In main declare variables x and y. Write the definition of the function that gets
the value of x. The function then changes the value of x by assigning the value
of the expression 2 times the (old) value of x plus the value of y minus the value
entered by the user.

Code Output
#include<iostream>
using namespace std;
void funcone(int x);
int main() * Before Fun Of X and
{ Y*
int x,y; X= 5
cout<<"* Before Fun Of X and Y *"<<endl; Y= 3
x=5; ** After Fun X and Y **
y=3; X= 8
cout<<"X= "<<x<<endl;
cout<<"Y= "<<y<<endl; Process returned 0 (0x0)
funcone(x); execution time : 0.018 s
return 0; Press any key to
} continue.
void funcone(int x)
{
int y=3;
x=((2*5)+3)-5;
cout<<"** After Fun X and Y **"<<endl;
cout<<"X= "<<x<<endl;
}
8.4.2 Write the definition of the function next Char that sets the value of z to the
next character stored in z using reference variable.

Code Output
#include <iostream>
#include <iomanip>
using namespace std ; Enter character :
void nextChar ( char ) ; a
int main() The character stored in
{ 'ch' after incriment is: b
char z ;
nextChar ( z ) ;
} Process returned 0 (0x0)
void nextChar ( char ch ) execution time : 2.252 s
{ Press any key to
cout << "Enter character : " << endl ; continue.
cin>>ch;
ch = ++ch ;
cout << "The character stored in 'ch' after incriment
is: " << ch << endl << endl ;
}
8.4.3 Write a program that will take an integer value in main function. And use a
void function to convert it to its absolute value.

Code Output
#include <iostream> Enter 6 numbers:
using namespace std; 1
int main() { 5
int numbers[2][3]; 4
cout << "Enter 6 numbers: " << endl; 5
for (int i = 0; i < 2; ++i) { 5
for (int j = 0; j < 3; ++j) { 4
cin >> numbers[i][j]; The numbers are:
} numbers[0][0]: 1
} numbers[0][1]: 5
cout << "The numbers are: " << endl; numbers[0][2]: 4
for (int i = 0; i < 2; ++i) { numbers[1][0]: 5
for (int j = 0; j < 3; ++j) { numbers[1][1]: 5
cout << "numbers[" << i << "][" << j << "]: " << numbers[1][2]: 4
numbers[i][j] << endl;
} Process returned 0 (0x0)
} execution time : 8.383 s
return 0; Press any key to
} continue.
8.4.4 Write a program that will take two numbers as first and second numbers of
Fibonacci Series. And then generate the series up to the given number using a
void function.

Code Output
#include <iostream> enter the position
using namespace std; 3
int main() the fabonnic series are as
follows
{ 12
int fib1 = 0, fib2 = 1, fib3 = 1,n;
cout<<"enter the position" <<endl;
cin>>n;
cout<<"the fabonnic series are as follows" <<endl;
while (fib1 + fib2 <n)
{
fib3 = fib1 + fib2;
fib1 = fib2;
fib2 = fib3;
cout<< fib3 << " ";}
cout<<endl;
return 0;

}
GENERALIZED LAB RUBRICS

Component with Above Meeting Approaching Below Weight / Score


Used
Taxonomy Expectation (4) Expectation (3) Expectation (2) Expectation (1) 100 (1–4)
Is able to build a Is able to assemble a Is only able to Is not able to
given setup neatly given setup using copy a given assemble a given
and timely using correct hardware setup using setup using
correct hardware components after correct hardware correct hardware
Building
components and / minor revisions components components ☐
(Hardware) – P4
or can reorganize /
adapt to new /
special
requirements
Recording Is able to record Is able to record Is only able to Is unable to
Measurements accurate accurate record accurate record accurate

(Hardware / measurements all measurements most measurements on measurements
Software) – C3 the time of the time some occasions
Is able to Is able to Is not able to Is unable to
formulate/develop evaluate/conclude evaluate/conclude comprehend
theories in correctly about correctly about investigation
addition to investigation investigation parameters
Investigation
evaluating/conclu parameters by parameters by
(Hardware / ☐
ding correctly assessing data assessing data
Software) – C5
about
investigation
parameters by
assessing data
Design / Is able to design / Is able to design / Is able to Is unable to
Development of develop the develop the solution partially design / partially design /
Solution solution of a given of a given problem develop the develop the ☐
(Hardware / problem and add solution of a solution of a
Software) – C6 features to it given problem given problem
Is adept in the use Is able to use the Is able to use the Is unable to use
of software tool software tool software tool but the software tool
Software Usage
and can access effectively by cannot access all ☐
(Software) – C3
advanced features accessing all the the required
required features features
Is able to Is able to complete a Is able to Is unable to
efficiently given task using partially partially
complete a given required complete a given complete a given
task using programming task task
Programming advanced language constructs
Language programming / methods /

(Software) – C3– language commands
C6 constructs /
methods /
commands and/or
add features to the
original task

Additional Comments (if any):

----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
GENERALIZED LAB RUBRICS

Component with Above Meeting Expectation Approaching Below Weight Score


Used
Taxonomy Expectation (4) (3) Expectation (2) Expectation (1) / 100 (1–4)
Assesses and Assesses and
Safety Assesses and Assesses and
complies with complies with
Instructions complies with all complies with most
some EHS few EHS ☐
(PLO6) EHS instructions EHS instructions
instructions while instructions in
A4 while in lab while in lab
in lab lab
Does not
exhibit
Makes an effort to
Exhibits exemplary professional
Exhibits professional exhibit
Professional professional ethics ethics while
ethics while dealing professional ethics
Ethics while dealing with dealing with
with fellow students, while dealing with ☐
(PLO8) fellow students, lab fellow
lab staff and fellow students, lab
A3 staff and instructor students, lab
instructor all the time staff and instructor
all the time staff and
all the time
instructor all
the time
Consistently shows Shows some
full preparation by Consistently shows preparation which Shows very
completing all full preparation by is mostly at little or no
Contribution
agreed tasks and completing all agreed superficial level in preparation in
(PLO9) ☐
provides additional tasks and work completing a task completing a
A5
resources for the requires little or no and work requires task and work
group and work revisions much revisions and quality is poor
quality is excellent editing
Internalized Neither helpful nor
Consistent positive Discouraging
Attitude positive behavior damaging and
behavior most of the behavior
(PLO9) and encourages and shows disinterest in ☐
time towards other towards other
A5 helps other team the performance of
team members team members
members others
Report on all
relevant sections
Report on all Report on all relevant
related to the lab
relevant sections sections related to the
tasks is completed Report on all
related to the lab lab tasks is completed
but many relevant
Report Writing tasks is completed but few deficiencies
deficiencies are sections related
(PLO10) accurately, meeting are present in terms of ☐
present in terms of to the lab tasks
A2 the requirements, accuracy / meeting
accuracy / meeting is not
in prescribed time the requirements /
the requirements / completed
and with good prescribed time / good
prescribed time /
language skills language skills
good language
skills
Manages tasks well Manages tasks within Manages tasks in Does not
Lab Task
within given given timeframe an extended manage tasks
Management
timeframe timeframe even in ☐
(PLO11)
extended
A3
timeframes

Additional Comments (if any):


----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
9 DESIGN OF ATM MODEL (OPEN-ENDED LAB)

9.1 PROCEDURES

The code carries out all the functions that all standard atm machines do. You can check
amount present in your account, withdraw balance and deposit amount.
When you run the project compiled code in visual studio ide or its exe file. A text
message will pop up on the screen of the display “PLEASE ENTER THE PINCODE “.
Now enter the pin code assigned to users above. Pin code must be of the person in
whose account you want to withdraw, deposit or print the balance receipt.

9.2 OBSERVATION AND RESULTS

When you run the project compiled code in visual studio ide or its exe file. A text
message will pop up on the screen of the display “PLEASE ENTER THE PINCODE “.
Now enter the pin code assigned to users above. Pin code must be of the person in
whose account you want to withdraw, deposit or print the balance receipt.

9.3 LEARNING OUTCOMES

In this open-ended lab, I have come to know about the security system of the Bank ATMs
And I also learned how to construct a security code for ATM
9.4 EXERCISE QUESTIONS

9.4.1 Write a C++ program that will allow a consumer to withdraw funds from their
bank accounts (savings or current) using ATM machine. The program can
check the balance of their bank account, choose the amount to withdraw, show
the remaining balance etc. Assume some amount as initial balance in account.

Code Output
#include <iostream>
#include <conio.h>
#include <string.h>
using namespace std;

int main ()
{ Enter your pin: 1998
int deposit=0;
int amount=5000; Pin Approved!
int withdraw= 0;
int choice=0; Welcome to Burhan's
int pin=0; special ATM
char keypin; 1. Check Balance
keypin = 1998; 2. Withdraw
char comppin; 3. Deposit
4. Exit
cout << "Enter your pin: ";
cin >> pin;

comppin= (pin, keypin); Enter Number: 1

if (pin==1998) Your current balance is:


{ 5000
cout << "\nPin Approved!\n"; Enter Number: 2

Enter the amount you want


cout << "\n\t Welcome to Burhan's special ATM "; to withdraw: 3333
cout << "\n\t 1. Check Balance ";
cout << "\n\t 2. Withdraw "; Your current balance is:
cout << "\n\t 3. Deposit "; 1667
cout << "\n\t 4. Exit "; Enter Number: 3
cout << "\n\t ";
Enter the amount you want
cout << "\n\n"; to deposit: 454

int balance=1; Your current balance is:


int withdraw=2; 2121
int deposit=3;
int Exit=4;

s:
cout << "\nEnter Number: ";
cin >> choice;
if (choice==1)
{
cout <<"\nYour current balance is: \n" << amount;
goto s;
}

else if (choice==2)
{
cout << "\nEnter the amount you want to withdraw: ";
cin >> withdraw;

if (withdraw>amount)
{
cout << "\nYou don't have sufficient balance.\n";
goto s;
}

else
{
amount=amount-withdraw;
cout << "\nYour current balance is: \n" << amount;

goto s;
}
}

else if (choice==3)
{
cout << "\nEnter the amount you want to deposit: ";
cin >> deposit;

amount=amount+deposit;

cout << "\nYour current balance is: \n" << amount;

goto s;
}

else if (choice==4)
{
cout << "\nTHANK YOU!";
}

else if (pin!=0)
{
cout << "\nInvalid pin!" << "\nPlease try again.";
}

return 0;
getch();

}
The open-ended lab task qualifies as a Complex Engineering Problem as it meets the criterion 1
and 3:

S# Attribute Complex Problems = 1 &(2 | 3 | 4 | 5 | 6 | 7 | 8 | 9)

Engineering problems which cannot be resolved


1 Preamble without in-depth engineering knowledge, and have ☒
some or all of the characteristics listed below:

Range of conflicting Involve wide-ranging or conflicting technical,


2 ☐
requirements engineering and other issues.

Have no obvious solution and require abstract thinking,


3 Depth of analysis required ☒
originality in analysis to formulate suitable models.

Requires research-based knowledge much of which is


Depth of knowledge at, or informed by, the forefront of the professional
4 ☐
required discipline and which allows a fundamentals-based, first
principles analytical approach.

5 Familiarity of issues Involve infrequently encountered issues ☐

Are outside problems encompassed by standards and


6 Extent of applicable codes ☐
codes of practice for professional engineering.

Extent of stakeholder
Involve diverse groups of stakeholders with widely
7 involvement and level of ☐
varying needs.
conflicting requirements

8 Consequences Have significant consequences in a range of contexts. ☐

Are high level problems including many component


9 Interdependence ☐
parts or sub-problems?

S
Attribute Complex Problems = 1 & (2 | 3 | 4 | 5 | 6 | 7 | 8 | 9)
#

Engineering problems which cannot be resolved


1 Preamble without in-depth engineering knowledge, and have ☒
some or all of the characteristics listed below:

Range of conflicting Involve wide-ranging or conflicting technical,


2 ☐
requirements engineering and other issues.

Have no obvious solution and require abstract


3 Depth of analysis required thinking, originality in analysis to formulate suitable ☒
models.
S
Attribute Complex Problems = 1 & (2 | 3 | 4 | 5 | 6 | 7 | 8 | 9)
#

Requires research-based knowledge much of which is


Depth of knowledge at, or informed by, the forefront of the professional
4 ☐
required discipline and which allows a fundamentals-based,
first principles analytical approach.

5 Familiarity of issues Involve infrequently encountered issues ☐

Are outside problems encompassed by standards and


6 Extent of applicable codes ☐
codes of practice for professional engineering.

Extent of stakeholder
Involve diverse groups of stakeholders with widely
7 involvement and level of ☐
varying needs.
conflicting requirements

8 Consequences Have significant consequences in a range of contexts. ☐

Are high level problems including many component


9 Interdependence ☐
parts or sub-problems?
GENERALIZED LAB RUBRICS

Component with Above Meeting Approaching Below Weight / Score


Used
Taxonomy Expectation (4) Expectation (3) Expectation (2) Expectation (1) 100 (1–4)
Is able to build a Is able to assemble a Is only able to Is not able to
given setup neatly given setup using copy a given assemble a given
and timely using correct hardware setup using setup using
correct hardware components after correct hardware correct hardware
Building
components and / minor revisions components components ☐
(Hardware) – P4
or can reorganize /
adapt to new /
special
requirements
Recording Is able to record Is able to record Is only able to Is unable to
Measurements accurate accurate record accurate record accurate

(Hardware / measurements all measurements most measurements on measurements
Software) – C3 the time of the time some occasions
Is able to Is able to Is not able to Is unable to
formulate/develop evaluate/conclude evaluate/conclude comprehend
theories in correctly about correctly about investigation
addition to investigation investigation parameters
Investigation
evaluating/conclu parameters by parameters by
(Hardware / ☐
ding correctly assessing data assessing data
Software) – C5
about
investigation
parameters by
assessing data
Design / Is able to design / Is able to design / Is able to Is unable to
Development of develop the develop the solution partially design / partially design /
Solution solution of a given of a given problem develop the develop the ☐
(Hardware / problem and add solution of a solution of a
Software) – C6 features to it given problem given problem
Is adept in the use Is able to use the Is able to use the Is unable to use
of software tool software tool software tool but the software tool
Software Usage
and can access effectively by cannot access all ☐
(Software) – C3
advanced features accessing all the the required
required features features
Is able to Is able to complete a Is able to Is unable to
efficiently given task using partially partially
complete a given required complete a given complete a given
task using programming task task
Programming advanced language constructs
Language programming / methods /

(Software) – C3– language commands
C6 constructs /
methods /
commands and/or
add features to the
original task

Additional Comments (if any):

----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
GENERALIZED LAB RUBRICS

Component with Above Meeting Expectation Approaching Below Weight Score


Used
Taxonomy Expectation (4) (3) Expectation (2) Expectation (1) / 100 (1–4)
Assesses and Assesses and
Safety Assesses and Assesses and
complies with complies with
Instructions complies with all complies with most
some EHS few EHS ☐
(PLO6) EHS instructions EHS instructions
instructions while instructions in
A4 while in lab while in lab
in lab lab
Does not
exhibit
Makes an effort to
Exhibits exemplary professional
Exhibits professional exhibit
Professional professional ethics ethics while
ethics while dealing professional ethics
Ethics while dealing with dealing with
with fellow students, while dealing with ☐
(PLO8) fellow students, lab fellow
lab staff and fellow students, lab
A3 staff and instructor students, lab
instructor all the time staff and instructor
all the time staff and
all the time
instructor all
the time
Consistently shows Shows some
full preparation by Consistently shows preparation which Shows very
completing all full preparation by is mostly at little or no
Contribution
agreed tasks and completing all agreed superficial level in preparation in
(PLO9) ☐
provides additional tasks and work completing a task completing a
A5
resources for the requires little or no and work requires task and work
group and work revisions much revisions and quality is poor
quality is excellent editing
Internalized Neither helpful nor
Consistent positive Discouraging
Attitude positive behavior damaging and
behavior most of the behavior
(PLO9) and encourages and shows disinterest in ☐
time towards other towards other
A5 helps other team the performance of
team members team members
members others
Report on all
relevant sections
Report on all Report on all relevant
related to the lab
relevant sections sections related to the
tasks is completed Report on all
related to the lab lab tasks is completed
but many relevant
Report Writing tasks is completed but few deficiencies
deficiencies are sections related
(PLO10) accurately, meeting are present in terms of ☐
present in terms of to the lab tasks
A2 the requirements, accuracy / meeting
accuracy / meeting is not
in prescribed time the requirements /
the requirements / completed
and with good prescribed time / good
prescribed time /
language skills language skills
good language
skills
Manages tasks well Manages tasks within Manages tasks in Does not
Lab Task
within given given timeframe an extended manage tasks
Management
timeframe timeframe even in ☐
(PLO11)
extended
A3
timeframes

Additional Comments (if any):


----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
10 ARRAYS

10.1 PROCEDURES

• On your personal computer.


• Open the code block.
• Create a new file.
• Write a program.
• Now compile and run a program.
• Output will show on your screen.

10.2 OBSERVATION AND RESULTS

The array indices start with 0. Meaning x [0] is the first element stored at index 0. If size of
array is n last element would be store in (n-1).

10.3 LEARNING OUTCOMES

We learn from this lab that Arrays are used to store multiple values in a single
variable, instead of declaring separate variables for each value.
10.4 EXERCISE QUESTIONS

10.4.1 Write a program that declares an array of 10 elements of type int. Initialize
each element of array with cube of the index variable. Then display all values
in the array using loop.

Code Output
#include<iostream>
using namespace std; 0
int main( ) 1
{ 8
int num[10]; 27
num[0]=0; 64
num[1]=1; 125
num[2]=8; 216
num[3]=27; 343
num[4]=64; 512
num[5]=125; 729
num[6]=216;
num[7]=343; Process returned 0 (0x0)
num[8]=512; execution time : 0.023 s
num[9]=729; Press any key to
int i; continue.
for(i=0;i<10;i++)
{
cout<<num[i]<<endl;
}
return 0;
}
10.4.2 Write a program that declares an integer array of size 10 and reads values
from user in it. Then find out how many elements are even and how many are
odd.

Code Output
#include<iostream> Enter size of the array

using namespace std; 3

int main () Enter elements of the array


Enter the element arr[0] :
{ 2

int arr[100]; Enter the element arr[1] :

int i,size,odd=0,even=0; 4

cout<<"Enter size of the array"; Enter the element arr[2] :


cin>>size; 5

cout<<"Enter elements of the array"; Total even numbers of an


array :2
for(i=0; i<size; i++) Total odd numbers of an
array : 1
{

cout<<"Enter the element arr["<<i<<"] :"<<endl;

cin>>arr[i];

for(i=0; i<size; i++)

if(arr[i]%2==0)

even++;

Else

odd++;

}
}
cout<<"Total even numbers of an array :"<<even<<endl;
cout<<"Total odd numbers of an array : "<<odd<<endl;

10.4.3 Write a program that declares an integer array of size 10 and reads values
from user in it. Then replace its negative elements with same positive values.

Code Output

#include<iostream> Enter 10 numbers=

Using namespace std; 1

Int main () 2

{ -3

int countp=0, countn=0, countz=0, arr[10], i; 3

cout<<"Enter 10 numbers : "; 4


for(i=0; i<10; i++) -4

{ 5

cin>>arr[i]; 6

} 7

for(i=0; i<10; i++) -8

{ Positive number are=7

if(arr[i]<0) Negative number are=3

{
countn++;
}
else if(arr[i]==0)
{
countz++;
}
Else
{
countp++;
}
cout<<"Positive Numbers = "<<countp<<"\n";
cout<<"Negative Numbers = "<<countn<<"\n";
cout<<"Zero = "<<countz<<"\n";
return 0;
}

10.4.4 Write a program that takes an integer array of size 10 from user then prints
the smallest and largest element of the array.

Code Output

#include<iostream> Enter size of array=10


Enter element of
using namespace std;
array=2,4
Int main() Largest element is=4
{ Smallest element is=2

int arr[10], n, i, max, min;


cout <<"Enter the size of the array : ";
cin >> n;
cout <<"Enter the elements of the array : ";
for (i = 0; i < n; i++)
cin >> arr[i];
max = arr[0];
for (i = 0; i < n; i++)
{
if (max < arr[i])
max = arr[i];
}
min = arr[0];
for (i = 0; i < n; i++)
{
if (min > arr[i])
min = arr[i];
}
cout <<"Largest element : "<< max;
cout <<"Smallest element : "<< min;
Return 0;
}

10.4.5 Write a program that takes an integer array of size 10 from user then shifts
it’s all elements to the left and its first element on the last location. (Circular
Shift Right)

Code Output

#include<iostream> Enter 10 element array

Using namespace std; 1

Int main() 2
{ 3

Int n,I; 4

Int arr[size]; 5

Cout<<”enter 10 element array”<<endl; 6

For(I=0;I<size;I++) 7

{ 8

Cout<<arr[I]; 9

} 10
Enter number of time to
Cout<<”enter number of time to left rotate”<<endl;
left rotate=2
Array after
Cin>>n;
rotation=array(arr)
N=n%size;
Cout<<”array before rotation”<<endl;
Cout<<array(arr);
For(I=1;I<=n;I++)
{
Cout<<Rotate by one(arr);
}
Cout<<”array aftar rotation”<<endl;
Cout<<array(arr);
return0;
}
GENERALIZED LAB RUBRICS

Component with Above Meeting Approaching Below Weight / Score


Used
Taxonomy Expectation (4) Expectation (3) Expectation (2) Expectation (1) 100 (1–4)
Is able to build a Is able to assemble a Is only able to Is not able to
given setup neatly given setup using copy a given assemble a given
and timely using correct hardware setup using setup using
correct hardware components after correct hardware correct hardware
Building
components and / minor revisions components components ☐
(Hardware) – P4
or can reorganize /
adapt to new /
special
requirements
Recording Is able to record Is able to record Is only able to Is unable to
Measurements accurate accurate record accurate record accurate

(Hardware / measurements all measurements most measurements on measurements
Software) – C3 the time of the time some occasions
Is able to Is able to Is not able to Is unable to
formulate/develop evaluate/conclude evaluate/conclude comprehend
theories in correctly about correctly about investigation
addition to investigation investigation parameters
Investigation
evaluating/conclu parameters by parameters by
(Hardware / ☐
ding correctly assessing data assessing data
Software) – C5
about
investigation
parameters by
assessing data
Design / Is able to design / Is able to design / Is able to Is unable to
Development of develop the develop the solution partially design / partially design /
Solution solution of a given of a given problem develop the develop the ☐
(Hardware / problem and add solution of a solution of a
Software) – C6 features to it given problem given problem
Is adept in the use Is able to use the Is able to use the Is unable to use
of software tool software tool software tool but the software tool
Software Usage
and can access effectively by cannot access all ☐
(Software) – C3
advanced features accessing all the the required
required features features
Is able to Is able to complete a Is able to Is unable to
efficiently given task using partially partially
complete a given required complete a given complete a given
task using programming task task
Programming advanced language constructs
Language programming / methods /

(Software) – C3– language commands
C6 constructs /
methods /
commands and/or
add features to the
original task

Additional Comments (if any):

----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
GENERALIZED LAB RUBRICS

Component with Above Meeting Expectation Approaching Below Weight Score


Used
Taxonomy Expectation (4) (3) Expectation (2) Expectation (1) / 100 (1–4)
Assesses and Assesses and
Safety Assesses and Assesses and
complies with complies with
Instructions complies with all complies with most
some EHS few EHS ☐
(PLO6) EHS instructions EHS instructions
instructions while instructions in
A4 while in lab while in lab
in lab lab
Does not
exhibit
Makes an effort to
Exhibits exemplary professional
Exhibits professional exhibit
Professional professional ethics ethics while
ethics while dealing professional ethics
Ethics while dealing with dealing with
with fellow students, while dealing with ☐
(PLO8) fellow students, lab fellow
lab staff and fellow students, lab
A3 staff and instructor students, lab
instructor all the time staff and instructor
all the time staff and
all the time
instructor all
the time
Consistently shows Shows some
full preparation by Consistently shows preparation which Shows very
completing all full preparation by is mostly at little or no
Contribution
agreed tasks and completing all agreed superficial level in preparation in
(PLO9) ☐
provides additional tasks and work completing a task completing a
A5
resources for the requires little or no and work requires task and work
group and work revisions much revisions and quality is poor
quality is excellent editing
Internalized Neither helpful nor
Consistent positive Discouraging
Attitude positive behavior damaging and
behavior most of the behavior
(PLO9) and encourages and shows disinterest in ☐
time towards other towards other
A5 helps other team the performance of
team members team members
members others
Report on all
relevant sections
Report on all Report on all relevant
related to the lab
relevant sections sections related to the
tasks is completed Report on all
related to the lab lab tasks is completed
but many relevant
Report Writing tasks is completed but few deficiencies
deficiencies are sections related
(PLO10) accurately, meeting are present in terms of ☐
present in terms of to the lab tasks
A2 the requirements, accuracy / meeting
accuracy / meeting is not
in prescribed time the requirements /
the requirements / completed
and with good prescribed time / good
prescribed time /
language skills language skills
good language
skills
Manages tasks well Manages tasks within Manages tasks in Does not
Lab Task
within given given timeframe an extended manage tasks
Management
timeframe timeframe even in ☐
(PLO11)
extended
A3
timeframes

Additional Comments (if any):


----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
11 2D ARRAYS

11.1 PROCEDURES

• Start your personal computer.


• Open code block which you have already install.
• Create a new project file.
• Now start write a program of a 2d array.
• After write a program then run it.
• Your output will show on screen.

11.2 OBSERVATION AND RESULTS

Two-dimensional array is an array within an array. It is an array of arrays. In


this type of array the position of a data element is referred by two indices instead
of one. So, it represents a table with rows and columns of data.

11.3 LEARNING OUTCOMES

A two-dimensional array is, in essence, a list of one-dimensional arrays. To


declare a two-dimensional integer array of size x , yyou would write something as
Array name[x][y]
11.4 EXERCISE QUESTIONS

11.4.1 Write a program that uses a two-dimensional array to store the highest and
lowest temperatures for each month of the year. The program should output
the average high, average low, and the highest and lowest temperatures for the
year.

Code Output
Please enter temperature
#include<iostream>
for month=
Using namespace std; 23
Total temperature
Int main()
was=120
{ Highest temperature was

double temperature; 23
Lowest temperature
double total=0;
was=
double avg=0; 20

double maxtemp=0;
double mintemp=0;
double a=0;
for (int i=0;i<12;i++)
{
cout<<"please enter temperature for
month"<<i+1<<":"<<endl;
cin>>temperature;
Total=temperature;
}
avg=total/12;
Maxtemp=temperature;
Mintemp=temperature;
for (int i=1;i<=12;i++)
{
a=temperature;
if(a<mintemp)
mintemp=a;
If(a>maxtemp)
maxtemp=a;
}
cout<<"totaltemperature
was"<<fixed<<showpoint<<total<<endl;
cout<<”averagetemperature
Was”<<fixed<<showpoint<<average<<endl;
cout<<"Heighesttemperature
was"<<fixed<<showpoint<<maxtemp<<endl;
cout<<"lowesttemperature
was"<<fixed<<showpoint<<mintemp<<endl;
Return 0;
}

11.4.2 A program that reads two 2-d arrays as 3*3 matrices then calculates and
stores their product into another 2-d array of size 3*3.

Code Output

#include<iostream> Enter matrix element=2

Using namespace std; Enter matrix element=3

Int main() Enter matrix element=4

{ Enter matrix element=5


int matrix1[3][3],matrix2[3][3],matrix3[3][3]; Enter matrix element=6

int i,j,k,rows,sum; Enter matrix element=7

cout<<"Enter Number in 1 matrix :"<<endl; Enter matrix element=8

for( i=0;i<3;i++){ Enter matrix element=9

for( j=0;j<3;j++) Martrix is not symmetric

{
cin>>matrix1[i][j];
}
}
cout<<"\n 1 Matrix You Entered\n;
for( i=0;i<3;i++){
for( j=0;j<3;j++)
{
cin>>matrix2[i][j];
}
}
cout<<"\n 2 Matrix You Entered\n";
for( i=0;i<3;i++){
for( j=0;j<3;j++)
{
cout<<matrix2[i][j];
}
cout<<endl;
}
cout<<"Multiplying two matrices...\n";
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
cout<<matrix3[i][j]<<"";
}
cout<<"\n";
}
Return 0;
}

11.4.3 A program that reads a 2-d array as 3*3 matrix then checks whether the
matrix is symmetric or not. A matrix is symmetric if mat [ i ] [ j ] = mat [ j ] [ i
] for all i and j except when i = j.

Code Output

#include<iostream> enter matrix element


using namespace std 3
2
int main()

{ 1
int matrix[3][3] 3
int I,j; 4
int flag=0; 6
for(i=0;i<3;i++) 7
{ 6
for(j=0;j<3;j++) 5
{ matrix is not symmetric
cout<<"enter matrix element"<<endl;
cin>>matrix[i][j];}}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{if(matrix[i][j]!=matrix[j][i])}
flag=1}}}
if (flag==1)
{
cout<<"matrix is not symmetric!"<<endl;
}
Else
{
cout<<"matrix is symmetric"<<endl;
}
Return 0;}
11.4.4 A program that reads a 2-d array as 3*3 matrix then calculates and prints its
Determinant.

Code Output
Calculate the
#include<iostream> determinent of 3*3
matrix=
Input element in first
Using namespace std;
matrix=
Void main() 1

{ 2

int arr1[10][10],i,j,n; 3

int det=0; 4

cout<<"Calculate the determinant of a 3 x 3 matrix"<<endl; 5

cout<<"Input elements in the first matrix :"<<endl; 1

for(i=0;i<3;i++) 2

{ 3

for(j=0;j<3;j++) 4
Determinent of matrix is
{
5
cout<<"element - [%d],[%d] : "<<i<<j<<endl;
cin>>arr1[i][j];
}
}
cout<<"The matrix is "<<endl;
for(i=0;i<3;i++)
{
for(j=0;j<3 ;j++)
cout<<"arr1[i][j]"<<endl;
}
for(i=0;i<3;i++)
det = det + (arr1[0][i]*(arr1[1][(i+1)%3]*arr1[2][(i+2)%3] -
arr1[1][(i+2)%3]*arr1[2][(i+1)%3]));
cout<<"The Determinant of the matrix is:"<<det<<endl;
Return 0;
}
GENERALIZED LAB RUBRICS

Component with Above Meeting Approaching Below Weight / Score


Used
Taxonomy Expectation (4) Expectation (3) Expectation (2) Expectation (1) 100 (1–4)
Is able to build a Is able to assemble a Is only able to Is not able to
given setup neatly given setup using copy a given assemble a given
and timely using correct hardware setup using setup using
correct hardware components after correct hardware correct hardware
Building
components and / minor revisions components components ☐
(Hardware) – P4
or can reorganize /
adapt to new /
special
requirements
Recording Is able to record Is able to record Is only able to Is unable to
Measurements accurate accurate record accurate record accurate

(Hardware / measurements all measurements most measurements on measurements
Software) – C3 the time of the time some occasions
Is able to Is able to Is not able to Is unable to
formulate/develop evaluate/conclude evaluate/conclude comprehend
theories in correctly about correctly about investigation
addition to investigation investigation parameters
Investigation
evaluating/conclu parameters by parameters by
(Hardware / ☐
ding correctly assessing data assessing data
Software) – C5
about
investigation
parameters by
assessing data
Design / Is able to design / Is able to design / Is able to Is unable to
Development of develop the develop the solution partially design / partially design /
Solution solution of a given of a given problem develop the develop the ☐
(Hardware / problem and add solution of a solution of a
Software) – C6 features to it given problem given problem
Is adept in the use Is able to use the Is able to use the Is unable to use
of software tool software tool software tool but the software tool
Software Usage
and can access effectively by cannot access all ☐
(Software) – C3
advanced features accessing all the the required
required features features
Is able to Is able to complete a Is able to Is unable to
efficiently given task using partially partially
complete a given required complete a given complete a given
task using programming task task
Programming advanced language constructs
Language programming / methods /

(Software) – C3– language commands
C6 constructs /
methods /
commands and/or
add features to the
original task

Additional Comments (if any):

----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
GENERALIZED LAB RUBRICS

Component with Above Meeting Expectation Approaching Below Weight Score


Used
Taxonomy Expectation (4) (3) Expectation (2) Expectation (1) / 100 (1–4)
Assesses and Assesses and
Safety Assesses and Assesses and
complies with complies with
Instructions complies with all complies with most
some EHS few EHS ☐
(PLO6) EHS instructions EHS instructions
instructions while instructions in
A4 while in lab while in lab
in lab lab
Does not
exhibit
Makes an effort to
Exhibits exemplary professional
Exhibits professional exhibit
Professional professional ethics ethics while
ethics while dealing professional ethics
Ethics while dealing with dealing with
with fellow students, while dealing with ☐
(PLO8) fellow students, lab fellow
lab staff and fellow students, lab
A3 staff and instructor students, lab
instructor all the time staff and instructor
all the time staff and
all the time
instructor all
the time
Consistently shows Shows some
full preparation by Consistently shows preparation which Shows very
completing all full preparation by is mostly at little or no
Contribution
agreed tasks and completing all agreed superficial level in preparation in
(PLO9) ☐
provides additional tasks and work completing a task completing a
A5
resources for the requires little or no and work requires task and work
group and work revisions much revisions and quality is poor
quality is excellent editing
Internalized Neither helpful nor
Consistent positive Discouraging
Attitude positive behavior damaging and
behavior most of the behavior
(PLO9) and encourages and shows disinterest in ☐
time towards other towards other
A5 helps other team the performance of
team members team members
members others
Report on all
relevant sections
Report on all Report on all relevant
related to the lab
relevant sections sections related to the
tasks is completed Report on all
related to the lab lab tasks is completed
but many relevant
Report Writing tasks is completed but few deficiencies
deficiencies are sections related
(PLO10) accurately, meeting are present in terms of ☐
present in terms of to the lab tasks
A2 the requirements, accuracy / meeting
accuracy / meeting is not
in prescribed time the requirements /
the requirements / completed
and with good prescribed time / good
prescribed time /
language skills language skills
good language
skills
Manages tasks well Manages tasks within Manages tasks in Does not
Lab Task
within given given timeframe an extended manage tasks
Management
timeframe timeframe even in ☐
(PLO11)
extended
A3
timeframes

Additional Comments (if any):


----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
12 STRINGS

12.1 PROCEDURES

• Start your personal computer.


• Open code block which you have already install.
• Create a new project file.
• Now start write a program of string.
• After write a program then run it.
• Your output will show on screen.

12.2 OBSERVATION AND RESULTS

We must invoke this on a string object, using another string as an argument.

The find () method will then check if the given string lies in our string. It will return

the size of the sub-string including the '\0' terminating character (as size_ t).

But if the string does not lie in our original string, it will return 0.

12.3 LEARNING OUTCOMES

In this lab I have come to know about the string concept in C++ language. And how to compile
the code.
12.4 EXERCISE QUESTIONS

12.4.1 Write a program that takes a string as input from user then converts its
capital letters into small letters and small letters into capital letters.

Code Output
#include <iostream>
using namespace std;
int lower_string(string str)
{
for(int i=0;str[i]!='\0';i++)
{
if (str[i] >= 'A' && str[i] <= 'Z')
str[i] = str[i] + 32;
}
cout<<"\n The string in lower case: "<< str;
}
int upper_string(string str)
{ Enter the string Burhan
for(int i=0;str[i]!='\0';i++)
The string in lower case:
{ burhan
if (str[i] >= 'a' && str[i] <= 'z') The string in upper case:
str[i] = str[i] - 32; BURHAN
}
cout<<"\n The string in upper case: "<< str;
}
int main()
{ string str;
cout<<"Enter the string ";
getline(cin,str);
lower_string(str);
upper_string(str);
return 0;
}

12.4.2 Write a program that takes a string as input from user then prints whether it
is palindrome or not. (Palindrome is a type of word play in which a word,
phrase, or sentence reads the same backward or forward).

Code Output
#include <iostream> Enter the string: 313
#include <string.h> 313 is a palindrome
using namespace std;
int main() Enter the string: 522
{ 522 is not a palindrome
char str1[20], str2[20];
int i, j, len = 0, flag = 0;
cout << "Enter the string : "; Process returned 0 (0x0)
gets(str1); execution time: 3.292 s
len = strlen(str1) - 1; Press any key to continue.
for (i = len, j = 0; i >= 0 ; i--, j++)
str2[j] = str1[i];
if (strcmp(str1, str2))
flag = 1;
if (flag == 1)
cout << str1 << " is not a palindrome";
else
cout << str1 << " is a palindrome";
return 0;
}

12.4.3 Write a program that takes a string as input from user then capitalize its each
word.

Code Output
#include<iostream.h> Enter a string: burhan
#include<conio.h> New string is: BURHAN
#include<stdio.h>

#include<ctype.h>

void main() {

clrscr();

int i;

char a[30];

cout<<“Enter a string:”;

gets(a);

for (i=0;a[i]!=’’;++i) {

if(i==0) {

if(islower(a[i]))

a[i]=toupper(a[i]);

} else {

if(a[i]!=’ ‘) {

if(isupper(a[i]))
a[i]=tolower(a[i]);

} else {

i++;

if(islower(a[i]))

a[i]=toupper(a[i]);

cout<<“nnNew string is: “<<a;


getch();
}

12.4.4 Write a program that takes a string as input then replaces all words of “is” by
“was”.

Code Output
#include<iostream>
using namespace std;
struct Replace
{
string str;
int j,i,k;
string key;
string repl;
enter the string:
}; Bunny
Original text: Bunny
int main() the edit text
{
Replace r1; Process returned 0 (0x0)
cout<< "enter the string:"<<endl; execution time : 4.216 s
getline(cin, r1.str);
Press any key to continue.
cout << "Original text: " << r1.str<<endl;
for (r1.j = 0; r1.j < r1.str.size(); r1.j++)
{
r1.key = r1.str.substr(r1.j, 3),r1.repl;
if (r1.key == "is")
{
r1.repl = "was";
for (r1.k = 0; r1.k < 3; r1.k++)
{
r1.str[r1.j+r1.k] = r1.repl[r1.k];
}
}
}
cout<<"the edit text"<<endl;
cout<<r1.repl;
return 0;
}
12.4.5 Write a program that takes two strings as input from user then prints whether
both strings are equal or not without using built-in function of strcmp ().

Code Output
#include<string.h>

int main()
{ Strings are equal
Value returned by strcmp()
char leftStr[] = "g f g"; is: 0
char rightStr[] = "g f g";
Process returned 0 (0x0)
int res = strcmp(leftStr, rightStr); execution time : 0.056 s
Press any key to continue.
if (res==0)
printf("Strings are equal");
else
printf("Strings are unequal");

printf("\nValue returned by strcmp() is: %d" , res);


return 0;
}
GENERALIZED LAB RUBRICS

Component with Above Meeting Approaching Below Weight / Score


Used
Taxonomy Expectation (4) Expectation (3) Expectation (2) Expectation (1) 100 (1–4)
Is able to build a Is able to assemble a Is only able to Is not able to
given setup neatly given setup using copy a given assemble a given
and timely using correct hardware setup using setup using
correct hardware components after correct hardware correct hardware
Building
components and / minor revisions components components ☐
(Hardware) – P4
or can reorganize /
adapt to new /
special
requirements
Recording Is able to record Is able to record Is only able to Is unable to
Measurements accurate accurate record accurate record accurate

(Hardware / measurements all measurements most measurements on measurements
Software) – C3 the time of the time some occasions
Is able to Is able to Is not able to Is unable to
formulate/develop evaluate/conclude evaluate/conclude comprehend
theories in correctly about correctly about investigation
addition to investigation investigation parameters
Investigation
evaluating/conclu parameters by parameters by
(Hardware / ☐
ding correctly assessing data assessing data
Software) – C5
about
investigation
parameters by
assessing data
Design / Is able to design / Is able to design / Is able to Is unable to
Development of develop the develop the solution partially design / partially design /
Solution solution of a given of a given problem develop the develop the ☐
(Hardware / problem and add solution of a solution of a
Software) – C6 features to it given problem given problem
Is adept in the use Is able to use the Is able to use the Is unable to use
of software tool software tool software tool but the software tool
Software Usage
and can access effectively by cannot access all ☐
(Software) – C3
advanced features accessing all the the required
required features features
Is able to Is able to complete a Is able to Is unable to
efficiently given task using partially partially
complete a given required complete a given complete a given
task using programming task task
Programming advanced language constructs
Language programming / methods /

(Software) – C3– language commands
C6 constructs /
methods /
commands and/or
add features to the
original task

Additional Comments (if any):

----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
GENERALIZED LAB RUBRICS

Component with Above Meeting Expectation Approaching Below Weight Score


Used
Taxonomy Expectation (4) (3) Expectation (2) Expectation (1) / 100 (1–4)
Assesses and Assesses and
Safety Assesses and Assesses and
complies with complies with
Instructions complies with all complies with most
some EHS few EHS ☐
(PLO6) EHS instructions EHS instructions
instructions while instructions in
A4 while in lab while in lab
in lab lab
Does not
exhibit
Makes an effort to
Exhibits exemplary professional
Exhibits professional exhibit
Professional professional ethics ethics while
ethics while dealing professional ethics
Ethics while dealing with dealing with
with fellow students, while dealing with ☐
(PLO8) fellow students, lab fellow
lab staff and fellow students, lab
A3 staff and instructor students, lab
instructor all the time staff and instructor
all the time staff and
all the time
instructor all
the time
Consistently shows Shows some
full preparation by Consistently shows preparation which Shows very
completing all full preparation by is mostly at little or no
Contribution
agreed tasks and completing all agreed superficial level in preparation in
(PLO9) ☐
provides additional tasks and work completing a task completing a
A5
resources for the requires little or no and work requires task and work
group and work revisions much revisions and quality is poor
quality is excellent editing
Internalized Neither helpful nor
Consistent positive Discouraging
Attitude positive behavior damaging and
behavior most of the behavior
(PLO9) and encourages and shows disinterest in ☐
time towards other towards other
A5 helps other team the performance of
team members team members
members others
Report on all
relevant sections
Report on all Report on all relevant
related to the lab
relevant sections sections related to the
tasks is completed Report on all
related to the lab lab tasks is completed
but many relevant
Report Writing tasks is completed but few deficiencies
deficiencies are sections related
(PLO10) accurately, meeting are present in terms of ☐
present in terms of to the lab tasks
A2 the requirements, accuracy / meeting
accuracy / meeting is not
in prescribed time the requirements /
the requirements / completed
and with good prescribed time / good
prescribed time /
language skills language skills
good language
skills
Manages tasks well Manages tasks within Manages tasks in Does not
Lab Task
within given given timeframe an extended manage tasks
Management
timeframe timeframe even in ☐
(PLO11)
extended
A3
timeframes

Additional Comments (if any):


----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
13 STRUCTURES AND UNIONS

13.1 PROCEDURES

Structures group members (data and functions) to create new data types. Structures

encapsulate data members (usually different data types), much like functions
encapsulate

program statements. Unions are like structures, but data members overlay (share)

memory, and unions may access members as different types. We use structures and

unions in applications that need user-defined types, such as databases, windows,

and graphics.

13.2 OBSERVATION AND RESULTS

A structure is a user-defined data type available in C that allows to combining data items
of

different kinds. Structures are used to represent a record. A union is a special data type

available in C that allows storing different data types in the same memory location.
13.3 LEARNING OUTCOMES

In this lab we have learned and become familiar with the structure and union.

13.4 EXERCISE QUESTIONS

13.4.1 Write a function called future Date. The function is to use two parameters.
The first parameter is a structure containing today’s date. The second
parameter is an integer showing the number of days after today. The function
returns a structure showing the next date, which may be in a future year.

Code Output
#include <iostream>
using namespace std; Enter Date: 28
Enter Month: 08
struct day Enter Year: 2020
{
int date; Your required date will
int month; come after days: 27
int year;
Date: 24
day() Month: 9
{ Year: 2020
do{
cout<<"Enter Date: "; Process returned 0 (0x0)
cin>>date; execution time : 28.078
}while(date>31); s
Press any key to
do{ continue.
cout<<"Enter Month: ";
cin>>month;
}while(month>12);

cout<<"Enter Year: ";


cin>>year;
}

void show();
};

day futureDate(day &a, int future)


{
int b=0;

while(b!=future)
{
if(a.year % 4 ==0 && a.month==2)
{
a.month++;
a.date=1;
b++;
}

if(a.date==30 && (a.month==4 || a.month==6 ||


a.month==9 || a.month==11))
{
a.month++;
a.date=1;
b++;
}

else if(a.date==29 && a.month==2)


{
a.month++;
a.date=1;
b++;
}

else if(a.date==31 && (a.month==1 || a.month==3 ||


a.month==5 || a.month==7 || a.month==8 ||
a.month==10))
{
a.month++;
a.date=1;
b++;
}

else if(a.date==31 && a.month==12)


{
a.year++;
a.month=1;
a.date=1;
b++;
}
else
{
a.date++;
b++;
}

return a;
}

void day::show()
{
cout<<endl<<"Date: "<<date<<endl;
cout<<"Month: "<<month<<endl;
cout<<"Year: "<<year<<endl;
}

int main()
{
day var;
int next;
cout<<endl<<"Your required date will come after days:
";
cin>>next;

futureDate(var, next);
var.show();

return 0;
}

13.4.2 Write a function called increment that accepts a date structure with three
fields each field is an integer, one for the month, one for the day in the month,
and one for the year. The function increments the date by one day and returns
the new date. If the date is the last day in the month, the month field must also
be changed. If the month is December, the value of the year field must also be
changed when the day is 31. A year is a leap year if it is evenly divisible by 4
but not by 100 or it is divisible by 400.

Code Output
#include <iostream> Enter Date: 27
using namespace std; Enter Month: 08
Enter Year: 2020
struct day
{ After Increment:
int date; Date: 28
int month; Month: 8
int year; Year: 2020
day() Process returned 0 (0x0)
{ execution time : 10.657
do{ s
cout<<"Enter Date: "; Press any key to
cin>>date; continue.
}while(date>31);

do{
cout<<"Enter Month: ";
cin>>month;
}while(month>12);

cout<<"Enter Year: ";


cin>>year;
}

void show();
};

day increment(day &a)


{
if(a.year % 4 ==0 && a.month==2)
{
a.month++;
a.date=1;
}

if(a.date==30 && (a.month==4 || a.month==6 ||


a.month==9 || a.month==11))
{
a.month++;
a.date=1;
}

else if(a.date==29 && a.month==2)


{
a.month++;
a.date=1;
}

else if(a.date==31 && (a.month==1 || a.month==3 ||


a.month==5 || a.month==7 || a.month==8 ||
a.month==10))
{
a.month++;
a.date=1;
}

else if(a.date==31 && a.month==12)


{
a.year++;
a.month=1;
a.date=1;
}

else
{
a.date++;
}
return a;
}

void day::show()
{
cout<<endl<<"After Increment: "<<endl;
cout<<"Date: "<<date<<endl;
cout<<"Month: "<<month<<endl;
cout<<"Year: "<<year<<endl;
}

int main()
{
day var;

increment(var);
var.show();

return 0;
}
13.4.3 Create a user defined structure type Rectangle with these integer members,
length and width. The program defines a rectangle r1 and initializes the
members according to user input. Then write a function recto square which
will take a rectangle type variable and calculate the area of that rectangle. It
will then return a structure square that will have an integer member a length

Code Output
#include<iostream> Enter length: 12
using namespace std; Enter width: 3
Area is 36
struct rectangle Process returned 0 (0x0)
{ execution time : 3.094 s
int l,w; Press any key to
}r1; continue.
int rectosquare(int l,int w)
{
int area =l*w;
cout<<"Area is "<<area;
}
int main()
{
int l,w;
cout<<"Enter length: ";
cin>>l;
cout<<"Enter width: ";
cin>>w;
rectosquare(l,w);
return 0;
}

13.4.4 Write a program that declares a struct to store the data of a Volunteer at an
NGO(Name, Age, City, Blood Group, Total Hours Volunteered.). Suppose
there are 7 volunteers, whose profile you need to maintain. Your program
must contain a function to input data and a function to output data

Code Output
#include<iostream> Enter city:
using namespace std; Enter blood group:
Enter hours:
Enter name:
struct volunteer Enter age:
{ Enter city:
string name; Enter blood group:
int age; Enter hours:
string city; Enter name:
string blood_grp; Enter age:
int hrs; Enter city:
}v[7]; Enter blood group:
Enter hours:
void getdata() Displaying information
{ Name: Burhan
cout<<endl; Age: 21
cout<<"Enter the information: "<<endl; City: lahore
for(int i=0;i<7;i++) Blood Group: B+
{ Hours: 16
cout<<"Enter name: "; Name: Waleed
cin>>v[i].name; Age: 21
cout<<endl; City: Lahore
cout<<"Enter age: "; Blood Group: A-
cin>>v[i].age; Hours: 14
cout<<endl; Name: Taimoor
cout<<"Enter city: "; Age: 0
cin>>v[i].city; City:
cout<<endl; Blood Group:
cout<<"Enter blood group: "; Hours: 0
cin>>v[i].blood_grp; Name:
cout<<endl; Age: 0
cout<<"Enter hours: "; City:
cin>>v[i].hrs; Blood Group:
cout<<endl; Hours: 0
} Name:
} Age: 0
City:
void display() Blood Group:
{ Hours: 0
cout<<"Displaying information"; Name:
cout<<endl; Age: 0
for(int i=0;i<7;i++) City:
{ Blood Group:
cout<<"Name: "<<v[i].name<<endl; Hours: 0
cout<<"Age: "<<v[i].age<<endl; Name:
cout<<"City: "<<v[i].city<<endl; Age: 0
cout<<"Blood Group: "<<v[i].blood_grp<<endl; City:
cout<<"Hours: "<<v[i].hrs<<endl; Blood Group:
} Hours: 0
}
int main() Process returned 0 (0x0)
{ execution time : 45.525
getdata(); s
display(); Press any key to
return 0; continue.
}
GENERALIZED LAB RUBRICS

Component with Above Meeting Approaching Below Weight / Score


Used
Taxonomy Expectation (4) Expectation (3) Expectation (2) Expectation (1) 100 (1–4)
Is able to build a Is able to assemble a Is only able to Is not able to
given setup neatly given setup using copy a given assemble a given
and timely using correct hardware setup using setup using
correct hardware components after correct hardware correct hardware
Building
components and / minor revisions components components ☐
(Hardware) – P4
or can reorganize /
adapt to new /
special
requirements
Recording Is able to record Is able to record Is only able to Is unable to
Measurements accurate accurate record accurate record accurate

(Hardware / measurements all measurements most measurements on measurements
Software) – C3 the time of the time some occasions
Is able to Is able to Is not able to Is unable to
formulate/develop evaluate/conclude evaluate/conclude comprehend
theories in correctly about correctly about investigation
addition to investigation investigation parameters
Investigation
evaluating/conclu parameters by parameters by
(Hardware / ☐
ding correctly assessing data assessing data
Software) – C5
about
investigation
parameters by
assessing data
Design / Is able to design / Is able to design / Is able to Is unable to
Development of develop the develop the solution partially design / partially design /
Solution solution of a given of a given problem develop the develop the ☐
(Hardware / problem and add solution of a solution of a
Software) – C6 features to it given problem given problem
Is adept in the use Is able to use the Is able to use the Is unable to use
of software tool software tool software tool but the software tool
Software Usage
and can access effectively by cannot access all ☐
(Software) – C3
advanced features accessing all the the required
required features features
Is able to Is able to complete a Is able to Is unable to
efficiently given task using partially partially
complete a given required complete a given complete a given
task using programming task task
Programming advanced language constructs
Language programming / methods /

(Software) – C3– language commands
C6 constructs /
methods /
commands and/or
add features to the
original task

Additional Comments (if any):

----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
GENERALIZED LAB RUBRICS

Component with Above Meeting Expectation Approaching Below Weight Score


Used
Taxonomy Expectation (4) (3) Expectation (2) Expectation (1) / 100 (1–4)
Assesses and Assesses and
Safety Assesses and Assesses and
complies with complies with
Instructions complies with all complies with most
some EHS few EHS ☐
(PLO6) EHS instructions EHS instructions
instructions while instructions in
A4 while in lab while in lab
in lab lab
Does not
exhibit
Makes an effort to
Exhibits exemplary professional
Exhibits professional exhibit
Professional professional ethics ethics while
ethics while dealing professional ethics
Ethics while dealing with dealing with
with fellow students, while dealing with ☐
(PLO8) fellow students, lab fellow
lab staff and fellow students, lab
A3 staff and instructor students, lab
instructor all the time staff and instructor
all the time staff and
all the time
instructor all
the time
Consistently shows Shows some
full preparation by Consistently shows preparation which Shows very
completing all full preparation by is mostly at little or no
Contribution
agreed tasks and completing all agreed superficial level in preparation in
(PLO9) ☐
provides additional tasks and work completing a task completing a
A5
resources for the requires little or no and work requires task and work
group and work revisions much revisions and quality is poor
quality is excellent editing
Internalized Neither helpful nor
Consistent positive Discouraging
Attitude positive behavior damaging and
behavior most of the behavior
(PLO9) and encourages and shows disinterest in ☐
time towards other towards other
A5 helps other team the performance of
team members team members
members others
Report on all
relevant sections
Report on all Report on all relevant
related to the lab
relevant sections sections related to the
tasks is completed Report on all
related to the lab lab tasks is completed
but many relevant
Report Writing tasks is completed but few deficiencies
deficiencies are sections related
(PLO10) accurately, meeting are present in terms of ☐
present in terms of to the lab tasks
A2 the requirements, accuracy / meeting
accuracy / meeting is not
in prescribed time the requirements /
the requirements / completed
and with good prescribed time / good
prescribed time /
language skills language skills
good language
skills
Manages tasks well Manages tasks within Manages tasks in Does not
Lab Task
within given given timeframe an extended manage tasks
Management
timeframe timeframe even in ☐
(PLO11)
extended
A3
timeframes

Additional Comments (if any):


----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
14 BANKING SCENARIO (OPEN-ENDED LAB)

14.1 PROCEDURES

• Start your personal computer.


• Open a code block software.
• Create a new file.
• Write a program according to the banking scenario.
• Then run a program and get output.

14.2 OBSERVATION AND RESULTS

In this lab I have generated a C++ code for the banking scenario and I have come to know
about how to generate this type of code for the safety of public and security of wealth of
public.

14.3 LEARNING OUTCOMES

In this lab I have generated a C++ code for the banking scenario and I have come to know

about how to generate this type of code for the safety of public and security of wealth of
public.
14.4 EXERCISE QUESTIONS

14.4.1 You are required to maintain a file record that will mimic a banking system.
Write a program that will first create a file to maintain customers record.
Your program will use various user-defined functions to add a new record,
update record, delete record and print a customer’s record given his ID card
number or bank account number. Add all fields that you think are necessary
to keep a customer’s record.

Code Output
#include<iostream> ***Account Information
System***
#include<fstream> Select one option below

#include<cstdlib> 1-->Add record to file

using std::cout; 2-->Show record from


file
using std::cin; 3-->Search Record
from file
using std::endl; 4-->Update Record

using std::fstream; 5-->Delete Record

using std::ofstream; 6-->Quit

using std::ifstream; Enter your choice: 1

using std::ios;

class account_query Enter Account Number: 11

{ Enter First Name: burhan

private: Enter Last Name: najeeb

char account_number[20]; Enter Balance: 50000

char firstName[10];

char lastName[10]; Select one option below

float total_Balance; 1-->Add record to file

public: 2-->Show record from


file
void read_data(); 3-->Search Record
from file
void show_data(); 4-->Update Record

void write_rec(); 5-->Delete Record

void read_rec(); 6-->Quit

void search_rec(); Enter your choice:


void edit_rec(); ***Account Information
System***
void delete_rec(); Select one option below

}; 1-->Add record to file

void account_query::read_data()
{
cout<<"\nEnter Account Number: ";
cin>>account_number;
cout<<"Enter First Name: ";
cin>>firstName;
cout<<"Enter Last Name: ";
cin>>lastName;
cout<<"Enter Balance: ";
cin>>total_Balance;
cout<<endl;
}
void account_query::show_data()
{
cout<<"Account Number: "<<account_number<<endl;
cout<<"First Name: "<<firstName<<endl;
cout<<"Last Name: "<<lastName<<endl;
cout<<"Current Balance: Rs. "<<total_Balance<<endl;
cout<<"-------------------------------"<<endl;
}
void account_query::write_rec()
{
ofstream outfile;
outfile.open("record.bank", ios::binary|ios::app);
read_data();
outfile.write(reinterpret_cast<char *>(this), sizeof(*this));
outfile.close();
}
void account_query::read_rec()
{
ifstream infile;
infile.open("record.bank", ios::binary);
if(!infile)
{
cout<<"Error in Opening! File Not Found!!"<<endl;
return;
}
cout<<"\n****Data from file****"<<endl;
while(!infile.eof())
{
if(infile.read(reinterpret_cast<char*>(this),
sizeof(*this))>0)
{
show_data();
}
}
infile.close();
}
void account_query::search_rec()
{
int n;
ifstream infile;
infile.open("record.bank", ios::binary);
if(!infile)
{
cout<<"\nError in opening! File Not Found!!"<<endl;
return;
}
infile.seekg(0,ios::end);
int count = infile.tellg()/sizeof(*this);
cout<<"\n There are "<<count<<" record in the file";
cout<<"\n Enter Record Number to Search: ";
cin>>n;
infile.seekg((n-1)*sizeof(*this));
infile.read(reinterpret_cast<char*>(this), sizeof(*this));
show_data();
}
void account_query::edit_rec()
{
int n;
fstream iofile;
iofile.open("record.bank", ios::in|ios::binary);
if(!iofile)
{
cout<<"\nError in opening! File Not Found!!"<<endl;
return;
}
iofile.seekg(0, ios::end);
int count = iofile.tellg()/sizeof(*this);
cout<<"\n There are "<<count<<" record in the file";
cout<<"\n Enter Record Number to edit: ";
cin>>n;
iofile.seekg((n-1)*sizeof(*this));
iofile.read(reinterpret_cast<char*>(this), sizeof(*this));
cout<<"Record "<<n<<" has following data"<<endl;
show_data();
iofile.close();
iofile.open("record.bank", ios::out|ios::in|ios::binary);
iofile.seekp((n-1)*sizeof(*this));
cout<<"\nEnter data to Modify "<<endl;
read_data();
iofile.write(reinterpret_cast<char*>(this), sizeof(*this));
}
void account_query::delete_rec()
{
int n;
ifstream infile;
infile.open("record.bank", ios::binary);
if(!infile)
{
cout<<"\nError in opening! File Not Found!!"<<endl;
return;
}
infile.seekg(0,ios::end);
int count = infile.tellg()/sizeof(*this);
cout<<"\n There are "<<count<<" record in the file";
cout<<"\n Enter Record Number to Delete: ";
cin>>n;
fstream tmpfile;
tmpfile.open("tmpfile.bank", ios::out|ios::binary);
infile.seekg(0);
for(int i=0; i<count; i++)
{
infile.read(reinterpret_cast<char*>(this),sizeof(*this));
if(i==(n-1))
continue;
tmpfile.write(reinterpret_cast<char*>(this),
sizeof(*this));
}
infile.close();
tmpfile.close();
remove("record.bank");
rename("tmpfile.bank", "record.bank");
}
int main()
{
account_query A;
int choice;
cout<<"***Acount Information System***"<<endl;
while(true)
{
cout<<"Select one option below ";
cout<<"\n\t1-->Add record to file";
cout<<"\n\t2-->Show record from file";
cout<<"\n\t3-->Search Record from file";
cout<<"\n\t4-->Update Record";
cout<<"\n\t5-->Delete Record";
cout<<"\n\t6-->Quit";
cout<<"\nEnter your choice: ";
cin>>choice;
switch(choice)
{
case 1:
A.write_rec();
break;
case 2:
A.read_rec();
break;
case 3:
A.search_rec();
break;
case 4:
A.edit_rec();
break;
case 5:
A.delete_rec();
break;
case 6:
exit(0);
break;
default:
cout<<"\nEnter corret choice";
exit(0);
}
}
system("pause");
return 0;
}
The open-ended lab task qualifies as a Complex Engineering Problem as it meets the criterion 1 and 3:

S
Attribute Complex Problems = 1 & (2 | 3 | 4 | 5 | 6 | 7 | 8 | 9)
#

Engineering problems which cannot be resolved


1 Preamble without in-depth engineering knowledge, and have ☒
some or all of the characteristics listed below:

Range of conflicting Involve wide-ranging or conflicting technical,


2 ☐
requirements engineering and other issues.

Have no obvious solution and require abstract


3 Depth of analysis required thinking, originality in analysis to formulate suitable ☒
models.

Requires research-based knowledge much of which is


Depth of knowledge at, or informed by, the forefront of the professional
4 ☐
required discipline and which allows a fundamentals-based,
first principles analytical approach.

5 Familiarity of issues Involve infrequently encountered issues ☐

Are outside problems encompassed by standards and


6 Extent of applicable codes ☐
codes of practice for professional engineering.

Extent of stakeholder
Involve diverse groups of stakeholders with widely
7 involvement and level of ☐
varying needs.
conflicting requirements

8 Consequences Have significant consequences in a range of contexts. ☐

Are high level problems including many component


9 Interdependence ☐
parts or sub-problems?
GENERALIZED LAB RUBRICS

Component with Above Meeting Approaching Below Weight / Score


Used
Taxonomy Expectation (4) Expectation (3) Expectation (2) Expectation (1) 100 (1–4)
Is able to build a Is able to assemble a Is only able to Is not able to
given setup neatly given setup using copy a given assemble a given
and timely using correct hardware setup using setup using
correct hardware components after correct hardware correct hardware
Building
components and / minor revisions components components ☐
(Hardware) – P4
or can reorganize /
adapt to new /
special
requirements
Recording Is able to record Is able to record Is only able to Is unable to
Measurements accurate accurate record accurate record accurate

(Hardware / measurements all measurements most measurements on measurements
Software) – C3 the time of the time some occasions
Is able to Is able to Is not able to Is unable to
formulate/develop evaluate/conclude evaluate/conclude comprehend
theories in correctly about correctly about investigation
addition to investigation investigation parameters
Investigation
evaluating/conclu parameters by parameters by
(Hardware / ☐
ding correctly assessing data assessing data
Software) – C5
about
investigation
parameters by
assessing data
Design / Is able to design / Is able to design / Is able to Is unable to
Development of develop the develop the solution partially design / partially design /
Solution solution of a given of a given problem develop the develop the ☐
(Hardware / problem and add solution of a solution of a
Software) – C6 features to it given problem given problem
Is adept in the use Is able to use the Is able to use the Is unable to use
of software tool software tool software tool but the software tool
Software Usage
and can access effectively by cannot access all ☐
(Software) – C3
advanced features accessing all the the required
required features features
Is able to Is able to complete a Is able to Is unable to
efficiently given task using partially partially
complete a given required complete a given complete a given
task using programming task task
Programming advanced language constructs
Language programming / methods /

(Software) – C3– language commands
C6 constructs /
methods /
commands and/or
add features to the
original task

Additional Comments (if any):

----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
GENERALIZED LAB RUBRICS

Component with Above Meeting Expectation Approaching Below Weight Score


Used
Taxonomy Expectation (4) (3) Expectation (2) Expectation (1) / 100 (1–4)
Assesses and Assesses and
Safety Assesses and Assesses and
complies with complies with
Instructions complies with all complies with most
some EHS few EHS ☐
(PLO6) EHS instructions EHS instructions
instructions while instructions in
A4 while in lab while in lab
in lab lab
Does not
exhibit
Makes an effort to
Exhibits exemplary professional
Exhibits professional exhibit
Professional professional ethics ethics while
ethics while dealing professional ethics
Ethics while dealing with dealing with
with fellow students, while dealing with ☐
(PLO8) fellow students, lab fellow
lab staff and fellow students, lab
A3 staff and instructor students, lab
instructor all the time staff and instructor
all the time staff and
all the time
instructor all
the time
Consistently shows Shows some
full preparation by Consistently shows preparation which Shows very
completing all full preparation by is mostly at little or no
Contribution
agreed tasks and completing all agreed superficial level in preparation in
(PLO9) ☐
provides additional tasks and work completing a task completing a
A5
resources for the requires little or no and work requires task and work
group and work revisions much revisions and quality is poor
quality is excellent editing
Internalized Neither helpful nor
Consistent positive Discouraging
Attitude positive behavior damaging and
behavior most of the behavior
(PLO9) and encourages and shows disinterest in ☐
time towards other towards other
A5 helps other team the performance of
team members team members
members others
Report on all
relevant sections
Report on all Report on all relevant
related to the lab
relevant sections sections related to the
tasks is completed Report on all
related to the lab lab tasks is completed
but many relevant
Report Writing tasks is completed but few deficiencies
deficiencies are sections related
(PLO10) accurately, meeting are present in terms of ☐
present in terms of to the lab tasks
A2 the requirements, accuracy / meeting
accuracy / meeting is not
in prescribed time the requirements /
the requirements / completed
and with good prescribed time / good
prescribed time /
language skills language skills
good language
skills
Manages tasks well Manages tasks within Manages tasks in Does not
Lab Task
within given given timeframe an extended manage tasks
Management
timeframe timeframe even in ☐
(PLO11)
extended
A3
timeframes

Additional Comments (if any):


----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------

You might also like