Computer System & Programming Lab Manual New
Computer System & Programming Lab Manual New
LABORATORY MANUAL
• Failure to conform to any of the above rules may result in not being
allowed to participate in the laboratory experiment.
IN CASE OF EMERGENCY:
Contact Persons
1. Muhammad Shoukat (Cell # +92 321 5731062)
2. Zeeshan (Cell # +92 301 5210454)
1
Computer Systems & Programming
Course Name
Bloom
CLOs Statement PLO
Taxonomy
2
Computer Systems & Programming
List of Experiments
Bloom
SN List of Experiments CLO PLO
Taxonomy
Functionalities and use of Word 2016 for writing
01 CLO-1 PLO-1 C1
reports and documents.
Application of Formulas and analyze the data in
02 CLO-1 PLO-1 C1
Excel 2016
Studying the preparation of PowerPoint
03 CLO-1 PLO-1 C1
Presentations PowerPoint 2016
Input/output command functions in C++
04 CLO-3 PLO-1 C1
Language
Application of Arithmetic and logical Operators
05 CLO-3 PLO-1 C1
in C++ Language
Relational Operators and Escape Sequences in
06 CLO-3 PLO-1 C2
C++ Language
Study the working of Conditional Statements (If
07 CLO-3 PLO-1 C2
Statement/ Switch Statement)
Working of Loops and application in programs
08 CLO-3 PLO-1 C3
(For Loop)
09 Processing of While loop and use in programs. CLO-3 PLO-1 C3
3
Computer Systems & Programming
excellent cognitive very good cognitive good cognitive skill cognitive skill for poor cognitive skill
devices (Marks: 5) +
skill for criterion 2 skill for criterion 2 for criterion 2 criterion 2 for criterion 2
Lab report
The statement The statement +
Programming skills The statement The statement The statement
characterizing the characterizing the Viva
and logics’ characterizing the characterizing the fair characterizing the
excellent very good
comprehension good psychomotor psychomotor skill for poor psychomotor
psychomotor skill for psychomotor skill for
(Marks: 5) skill for criterion 1 criterion 1 skill for criterion 1
criterion 1 criterion 1
4
Computer Systems & Programming
Experiment No. 01
1.1 Title
Exploring Word Processing and Presentation Design: A Hands-On Lab Experiment.
1.2 Objectives
Student able to editing, and formatting various types of written documents, such as
letters, reports, essays, and more. It aims to simplify the process of document
creation, allowing users to easily add text, images, tables, and other elements, while
also providing tools for adjusting the overall appearance and formatting of the
document.
1.3 Introduction
The Word Processing and Presentation Design lab experiment is designed to provide
students with practical experience in using two essential software tools: Microsoft
Word and PowerPoint. These programs are widely used in academic and professional
settings for creating written documents and visual presentations, and mastering them
can greatly enhance one's ability to communicate effectively.
During the lab experiment, participants will have the opportunity to learn and practice
various features and functionalities of Microsoft Word and PowerPoint, such as
creating and formatting documents, adding images and tables, and designing
professional-quality presentations. By the end of the lab experiment, students will
have developed practical skills that they can apply to their academic and professional
work, and be better equipped to communicate their ideas and messages through
written and visual media.
1.4 Apparatus
Hardware: Computer Systems
Software: Microsoft Office Suite
1.5 Conclusions
Students knows the basics of MS word and able to write and format the document.
5
Computer Systems & Programming
Experiment No. 02
2.1 Title
Application of Formulas data in Excel 2016
2.2 Objectives
Student able to Organize and store data in excel. Present data through charts, graphs.
Apply different built-in formulae and functions.
2.3 Introduction
Microsoft Excel is a spreadsheet software program used for organizing, analyzing, and
presenting data. It allows you to create and manage data in a grid-like format, with
columns and rows representing different data sets. You can use Excel to perform
calculations, create charts, graphs, and other visual representations of data, and
automate repetitive tasks with macros.
Excel provides a wide range of features and tools for data analysis, including formulas,
functions, and pivot tables. It also allows you to import and export data from various
sources, such as databases, text files, and other spreadsheets.
Whether you are working in finance, accounting, or another field, Excel provides a
powerful and flexible tool for managing, analyzing, and presenting data. With its wide
range of features and tools, Excel can help you gain insights, make informed decisions,
and communicate information effectively.
2.4 Apparatus
Hardware: Computer Systems
Software: Microsoft Office Suite
2.5 Conclusions
Students knows the basics of MS Excel and able to apply formulae and multiple
conditional formatting in MS excel.
6
Computer Systems & Programming
Experiment No. 03
3.1 Title
Studying the preparation of PowerPoint Presentations PowerPoint
2016
3.2 Objectives
Student able to Organize and store data in excel. Present data through charts, graphs.
Apply different built-in formulae and functions.
3.3 Introduction
The main objective of Microsoft PowerPoint is to create and deliver effective and
engaging presentations. Organize and present information in a visually appealing way.
Enhance presentations with images, charts, tables, and other multimedia elements.
Create dynamic slides and transitions to keep audiences engaged. Deliver
presentations in a variety of formats, including live presentations, video, and print.
3.4 Apparatus
Hardware: Computer Systems
Software: Microsoft Office Suite
3.5 Conclusions
Students can make presentations using different animations that are visually appealing
to the audience. Students able to demonstrate and explain the topics to the audience via
a Presentations using MS PowerPoint.
7
Computer Systems & Programming
Experiment No. 04
4.1 Title
Input/output commands and Application of Arithmetic operators in
C++.
4.2 Objectives
The objective of LAB Input/output commands in C++ is to familiarize learners with the
various ways to input and output data and Application of Arithmetic operators in C++
programming language.
Use the "cin" command to input data from the user
Use the "cout" command to output data to the console
Format the output to display data in a specific way
Use arithmetic operators such as addition, subtraction, multiplication, and division to
perform basic calculations.
Apply the modulus operator to perform division and retrieve the remainder.
4.3 Introduction
Input/Output commands are used in C++ programming language to interact with the
user and to display output on the console. In C++, the standard input and output
streams are provided by the iostream library, which allows for easy input and output
operations.
The "cin" command is used to read input from the user, while the "cout" command is
used to display output on the console. These commands can be used to input and
output various types of data, including integers, floating-point numbers, characters,
and strings.
Arithmetic operators, on the other hand, are used in C++ to perform basic arithmetic
operations on numeric data types such as integers and floating-point numbers. The
most common arithmetic operators are addition (+), subtraction (-), multiplication (*),
and division (/). In addition, the modulus operator (%) is used to perform division and
retrieve the remainder.
4.4 Apparatus
Hardware: Computer Systems
Software: Code Block
8
Computer Systems & Programming
Q No. 1 Write a C++ program that reads in an integer value from the user and then
outputs the square of that value.
Q No. 2 Write a C++ program that reads in a character value from the user and then
outputs the ASCII code for that character.
9
Computer Systems & Programming
Q No. 3 Write a C++ program that reads in an integer value from the user and then
outputs whether that value is even or odd.
Q No. 4 Write a C++ program that reads in two floating-point values from the user
and then outputs the result of raising the first value to the power of the second value.
10
Computer Systems & Programming
Q No. 5 Write a C++ program that reads in two integer values from the user and then
outputs the quotient and remainder of the division of the first value by the second
value.
Q No. 6 Write a program in provided space to find the number of bytes occupied
by various data types using the sizeof operator?
11
Computer Systems & Programming
Experiment No. 05
5.1 Title
Relational operators, logical Operators and escape sequences in C++.
5.2 Objectives
Relational operators: The primary objective of relational operators is to compare two
values and return a Boolean value (true or false) indicating whether the comparison is
true or false.
Logical operators: The primary objective of logical operators is to combine multiple
Boolean expressions and return a single Boolean value.
Escape sequences: The primary objective of escape sequences is to represent special
characters in a string literal. An escape sequence is a combination of a backslash () and
another character that represents a special character, such as a newline (\n), a tab (\t), a
backslash (\), or a double quote (").
5.3 Introduction
5.4 Apparatus
Hardware: Computer Systems
Software: Code Block
12
Computer Systems & Programming
Q No. 1 Write a program that tell the right most digit of the number entered by a user.
Hint: 12345 Right most digit is 5
654827 Right most digit is 7
Q No. 2 Write a program that asks the user to enter a score for three games, and then
displays the average of that three scores.
13
Computer Systems & Programming
Q No. 3 Write a program that will print the following using escape sequences.
*
**
***
****
*****
14
Computer Systems & Programming
15
Computer Systems & Programming
Experiment No. 06
6.1 Title
Study the working of Conditional Statements (If Statement).
6.2 Objectives
The main objective of conditional statements, specifically the if statement, is to allow
a program to make decisions based on certain conditions. The if statement provides a
way for a program to execute one set of statements if a certain condition is true, and
another set of statements if the condition is false.
6.3 Introduction
Controlling program flow: The if statement allows a program to selectively execute
certain code based on a specific condition. This helps to control the flow of the program
and ensures that the program runs in a specific way depending on the input or other
factors.
Handling user input: The if statement is often used to handle user input by checking
if the input is valid or not. If the input is valid, the program can proceed with the
intended operation. If the input is invalid, the program can prompt the user to enter
valid input.
Handling errors: The if statement is often used to handle errors or exceptions that
occur during program execution. If an error occurs, the program can use an if
statement to determine the appropriate course of action, such as printing an error
message or prompting the user to take corrective action.
6.4 Apparatus
Hardware: Computer Systems
Software: Code Block
16
Computer Systems & Programming
Q No. 1 Write a program that asks the user to enter a password and checks if it meets
the following requirements: it has at least 8 characters, contains at least one uppercase
letter, and contains at least one digit.
Q No. 2 Write a program that takes two integers as input and prints whether the first
integer is evenly divisible by the second integer.
17
Computer Systems & Programming
Q No. 3 Write a program that takes a character as input and prints "Vowel" if the
character is a vowel (a, e, i, o, u) and "Consonant" otherwise.
Q No. 4 Write a program that takes three integers as input and prints the largest of the
three integers.
18
Computer Systems & Programming
Q No. 5 Write a program in C++ that take a single character from the user, and tells
it's a Small Letter or it's a CAPITAL letter using nested if statement only.
19
Computer Systems & Programming
Q No. 6 Write a program that takes three integers as input and prints them in sorted
order (from smallest to largest) without using any loops.
20
Computer Systems & Programming
Experiment No. 07
7.1 Title
Study the working of Switch Statement.
7.2 Objectives
The switch statement is a conditional statement in C++ that allows a program to
evaluate an expression and execute different code blocks based on the value of that
expression.
7.3 Introduction
The switch statement evaluates the expression and then compares its value to one or
more constant expressions (called "case labels") using the case keyword. If the value
of the expression matches a case label, the corresponding block of code is executed.
The default keyword is used to specify a default block of code to execute if none of
the case labels match the expression value.
switch (expression) {
case constant-expression1:
// code block 1
break;
case constant-expression2:
// code block 2
break;
// more cases...
default:
// default code block
}
the break statement is used to terminate the code block for each case label. If a break
statement is not used, execution will continue to the next case label and so on, which
may not be what you want
7.4 Apparatus
Hardware: Computer Systems
Software: Code Block
21
Computer Systems & Programming
Q No. 1 Write a program that takes a grade (A, B, C, D, or F) as input and prints a
message indicating if the grade is passing or failing.
Q No. 2 Write a program that takes a day number (1-7) as input and prints the
corresponding day of the week (Monday, Tuesday, etc.) using a switch statement with
no break statements.
22
Computer Systems & Programming
Q No. 3 Write a program in C++ using switch statement to find largest number among
three variables.
Q No. 4 write a program to calculate the result of a simple arithmetic operation based
on the user's input.
23
Computer Systems & Programming
Experiment No. 08
8.1 Title
Working of Loops and application in programs (For Loop).
8.2 Objectives
The primary objective of loops is to execute a set of instructions repeatedly until a
certain condition is met. Loops provide a convenient way to automate repetitive tasks,
and they help to simplify code by reducing the need for redundant instructions.
8.3 Introduction
n C++, a for loop is a type of loop structure that allows a program to repeat a set of
instructions a specific number of times. The for loop consists of three parts:
initialization, condition, and increment/decrement.
1. Initialization: This is the first step in the for loop, and it is executed only once
at the beginning of the loop. It is used to declare and initialize the loop
variable(s), which is typically an integer that keeps track of the number of
times the loop has executed.
2. Condition: This is the second step in the for loop, and it specifies the condition
that must be true for the loop to continue executing. As long as the condition is
true, the code block within the for loop will be executed. Once the condition
becomes false, the loop will terminate.
3. Increment/Decrement: This is the third step in the for loop, and it is executed
at the end of each iteration. It is typically used to update the loop variable(s) to
ensure that the loop executes the desired number of times.
8.4 Apparatus
Hardware: Computer Systems
Software: Code Block
24
Computer Systems & Programming
Q No. 1 write a program to calculate the factorial of a number using a for loop.
Q No. 2write a program to find the prime numbers between 1 and 100 using a for loop.
25
Computer Systems & Programming
Q No. 3 Write a Prgram that will print the following pattern by taking no of rows as
input from user
1
12
123
1234
12345
26
Computer Systems & Programming
Q No. 4 Write a program to generate the Fibonacci sequence using a for loop.
Q No. 5 Write a program calculates the sum of numbers from 1 to n, where n is taken
as input from the user
27
Computer Systems & Programming
Experiment No. 09
9.1 Title
Processing of While loop and use in programs.
9.2 Objectives
The while loop in C++ is used to execute a block of code repeatedly as long as a certain
condition is true. The main objective of the while loop is to help automate repetitive
tasks and reduce code duplication.
9.3 Introduction
The while loop is a control flow statement in C++ that allows a block of code to be
executed repeatedly as long as a certain condition is true. The basic syntax of a while
loop is as follows:
while (condition) {
9.4 Apparatus
Hardware: Computer Systems
Software: Code Block
28
Computer Systems & Programming
Q No. 1 Write a Program to find the factorial of a number using while loop.
Q No. 2 Write a program to print the multiplication table of a given number using a
while loop.
29
Computer Systems & Programming
Q No. 3 Write a program to check if a given number is a prime number using a while
loop.
30
Computer Systems & Programming
Q No. 5 Write a program that asks the user to enter a positive integer and then prints
all the even numbers from 0 up to that integer.
Q No. 6 Write a program in C++ that take the integer type values for user and the
program terminates when the user enters 0 and after that your program will display
the average of those numbers, using while loop.
31
Computer Systems & Programming
Q No. 7 Write a Program in C++ that check the user defined number is Armstrong
or not.
Hint: 153 is an Armstrong number
(1)3+(5)3+(3)3=153
Q No. 8 Write a program that generates random numbers between 1 and 10 until it
generates the number 7 Print each generated number. (Hint: Use rand function in
cstdlib Library)
32
Computer Systems & Programming
Q No. 9 Write a program in C++ to find the perfect numbers between 1 and 500.
33
Computer Systems & Programming
Q No. 10 Write a C++ program that displays the sum of odd natural numbers using
while loop. The ending number should be entered by user.
Q No. 11 Write a program in C++ to display the sum of the series using while loop [ 9
+ 99 + 999 + 9999 ...].
34
Computer Systems & Programming
Experiment No. 10
10.1 Title
Processing of Do While loop and use in programs.
10.2 Objectives
The "do-while" loop in C++ is a control structure that allows a block of code to be
executed repeatedly until a certain condition is met. The key difference between a "do-
while" loop and a "while" loop is that the "do-while" loop guarantees that the code
block will be executed at least once, even if the condition is initially false.
10.3 Introduction
The "do-while" loop is a type of loop in C++ that allows a block of code to be
executed repeatedly based on a condition. The key difference between a "do-while"
loop and a "while" loop is that the "do-while" loop guarantees that the code block will
be executed at least once, even if the condition is initially false.
do {
// statements to be executed
} while (condition);
In this syntax, the statements within the curly braces are executed first, and then the
condition is evaluated. If the condition is true, the statements are executed again. This
process repeats until the condition becomes false.
10.4 Apparatus
Hardware: Computer Systems
Software: Code Block
35
Computer Systems & Programming
Q No. 1 Write a program that prompts the user to enter a positive integer and then prints
out all the even numbers between 0 and the entered number using a "do-while" loop.
Q No. 2 Write a program that prompts the user to enter a password and keeps prompting
them until they enter the correct password using a "do-while" loop.
36
Computer Systems & Programming
Q No. 3 Write a program that asks the user to enter a series of integers, and then
calculates the average of the numbers using a "do-while" loop.
Q No. 4 Write a program that asks the user to input a number and checks whether it is
a palindrome or not using a "do-while" loop.
37
Computer Systems & Programming
Q No.5 Write a program that generates the first n terms of the Fibonacci sequence using
a "do-while" loop. The Fibonacci sequence is a series of numbers where each number
is the sum of the two preceding numbers. The first two numbers in the sequence are 0
and 1.
38
Computer Systems & Programming
Experiment No. 11
11.1 Title
Study the working principle of Arrays: 1D Arrays and use in programs
11.2 Objectives
Understanding array syntax: Students should understand how to declare, initialize, and
access values in 1D arrays using proper syntax in C++.
Practice with loops: Loops are often used to iterate through arrays and perform
operations on the values. Students should practice using for loops and while loops to
iterate through arrays.
Manipulating arrays: Students should learn how to manipulate arrays by changing
values, sorting the array, or searching for values within the array.
11.3 Introduction
To access the values stored in an array, we use the array index notation. For example,
to access the value at index 2 of the numbers array, we write:
Note that arrays in C++ have a fixed size, which is determined at the time of
declaration. Once an array is declared, its size cannot be changed.
We can also declare and initialize an array in a single line, like this:
11.4 Apparatus
Hardware: Computer Systems
Software: Code Block
39
Computer Systems & Programming
Q No. 1 Write a program that reads in 10 integers from the user and stores them in an
array. The program should then print out the sum and average of the values in the array.
Q No. 2 Write a program that reads in an integer n from the user, and then generates an
array of n Fibonacci numbers (starting with 0 and 1). The program should then print
out the values in the array.
40
Computer Systems & Programming
Q No. 3 Write a program to find the minimum element in an array the array elements
should be entered by the user.
41
Computer Systems & Programming
Q No. 4 Write a program to find the frequency of each element in an array the array
elements should be entered by the user.
42
Computer Systems & Programming
43
Computer Systems & Programming
44
Computer Systems & Programming
Experiment No. 12
12.1 Title
Study the working Strings / String Input/output built-in functions
12.2 Objectives
Understanding string syntax: Students should be able to declare, initialize, and
manipulate strings using the correct syntax and functions.
Familiarity with common string operations: Students should be familiar with common
string operations, such as concatenation, comparison, and searching, and should be able
to implement these operations using C++ string functions.
12.3 Introduction
Strings in C++ are very versatile and are commonly used for a wide variety of tasks
such as storing text, manipulating text, and representing data in various formats.
To declare a string variable in C++, you can use the following syntax:
This will create a string variable called myString and initialize it with the value
"Hello, World!".
12.4 Apparatus
Hardware: Computer Systems
Software: Code Block
45
Computer Systems & Programming
46
Computer Systems & Programming
Q No.2 write a program to find the length of a string using built in function.
47
Computer Systems & Programming
48
Computer Systems & Programming
49
Computer Systems & Programming
Q No. 6 write a program to count the number of characters and words in a string:
50
Computer Systems & Programming
Experiment No. 13
13.1 Title
Studying the Working and implementation of Two-Dimensional Arrays and use
them in programs.
13.2 Objectives
Understanding the concept of two-dimensional arrays: The lab focus on helping
students understand what two-dimensional arrays are, how they differ from one-
dimensional arrays, and the various ways in which they can be used.
Creating and manipulating two-dimensional arrays: The lab may provide students with
hands-on experience in creating two-dimensional arrays and manipulating their
contents. This may involve techniques such as initializing arrays, assigning values to
specific elements, and iterating through arrays.
13.3 Introduction
In C++, you can declare a two-dimensional array using the following syntax:
type arrayName[rows][columns];
Here, "type" represents the data type of the elements in the array, "rows" represents
the number of rows in the array, and "columns" represents the number of columns in
the array.
13.4 Apparatus
Hardware: Computer Systems
Software: Code Block
51
Computer Systems & Programming
Q No. 1 write a program in C++ to multiply two matrices using 2D arrays also check
the multiplication is possible or not.
52
Computer Systems & Programming
53
Computer Systems & Programming
Q No. 3 Write a program in C++ that uses a 2D array to store the names and numbers
of students:
54
Computer Systems & Programming
Q No. 4 Write a program that will take inputs from user of 3 x 3 matrix and your
program will print its transpose.
55
Computer Systems & Programming
Experiment No. 14
14.1 Title
Procedure of declaring Functions in C Language. (User defined Functions)
14.2 Objectives
Understanding the concept of functions and their types in C++.
Learning how to define and declare functions in C++.
Understanding function parameters and return types in C++.
Understanding the scope and lifetime of variables in functions.
14.3 Introduction
In C++, a function is a block of code that performs a specific task. It can be called
from anywhere in the program to execute the code inside it. Functions can be used to
modularize code, making it easier to read, understand, and maintain.
In addition to the built-in functions provided by C++, programmers can also define
their own functions. These are called user-defined functions, and they can be created
to perform any task that the programmer needs.
return_type function_name(parameter_list) {
// function body
// code to perform task
// return statement (if applicable) }
The return_type specifies the data type of the value that the function returns. If the
function does not return a value, the return_type should be void.
The function_name is a name that the programmer chooses to identify the function.
It should be descriptive and easy to remember.
The parameter_list contains the list of input parameters that the function expects to
receive. Each parameter is specified as a data type followed by a variable name.
The function body contains the code that the function executes when it is called.
If the function returns a value, a return statement is used to return that value to the
calling function.
14.4 Apparatus
Hardware: Computer Systems
Software: Code Block
56
Computer Systems & Programming
Q No. 1 Write a program in C++ that has a function of square (). The user should enter
the number in main() and square of number should display in the function definition.
Q No. 2 Write a Program that get three integers numbers from user, pass them to
function, Add them and find the average in function body, Display the Average in main
function body.
57
Computer Systems & Programming
Q No. 3 Write a program in C++ that take 10 numbers from user the numbers should
be saved in array and find the largest using function.
58
Computer Systems & Programming
Q No. 4 Write a function that takes a character and a string as input, and returns the
number of occurrences of the character in the string. Call the function from the main()
function and display the result.
59