1|Page
PREPARED BY: MUHAMMAD ABSAR KHAN CONTACT US: 0319-3578201
2|Page
Author:
I am Muhammad Absar Khan, a dedicated educator
specializing in computer science and technology, currently
enriching young minds within the vibrant educational landscape
of Karachi. With a passion for fostering digital literacy and
innovation, I bring 7 years of experience in teaching a diverse
range of students, from secondary levels to intermediate levels.
My journey into the realm of education began with a profound
interest in technology, coupled with a desire to empower the next
generation with essential digital skills. I blend theoretical
knowledge with practical, hands-on learning experiences to
create a dynamic classroom environment.
In Karachi's ever-evolving educational milieu, I strive to not only
impart technical proficiency but also cultivate critical thinking, problem-solving, and creativity
among my students. By integrating cutting-edge tools and industry-relevant curriculum, I aim
to prepare them for the challenges of a digital future.
Beyond the classroom, I am committed to continuous professional development, staying
abreast of emerging trends and methodologies in educational technology. My goal is to inspire
curiosity and instill a lifelong love for learning in every student I teach.
I am excited to contribute to the intellectual growth of Karachi's youth and to collaborate with
fellow educators in shaping a generation of confident, tech-savvy global citizens.
I did my BS in Computer Technology from the University of Karachi and doing MS in Computer
Networks and Cyber Security from the Sir Syed University of Engineering and Technology.
I also trained my many of students in programming languages and as well as in graphics design.
I also offer online courses yearly on different modules like Graphics Designing 3.0, Hit the Python,
Explore UI Designing.
PREPARED BY: MUHAMMAD ABSAR KHAN CONTACT US: 0319-3578201
3|Page
PREPARED BY: MUHAMMAD ABSAR KHAN CONTACT US: 0319-3578201
4|Page
Q.1) What are the three control structures used in coding?
Sequence:
This is the simplest control structure, where instructions are executed one
after another in the exact order they appear in the code. Every step follows
in a sequence without any decision-making or looping.
Selection:
It includes if statement, if else statements to make it decision for program.
Which enables the program to roam into different paths so as it to be true
or false. If then else, Switch Statements are the examples of selection
structures.
Loops:
It enables a series of instructions to be iterated through several times. For,
While and Do-While: Loops are used to repeat a block of code until some
condition is true or false.
Q.2) Explain the difference between WHILE and DO-WHILE.
WHILE Loop DO-WHILE Loop
The condition is checked before the The condition is checked after the
loop starts. loop has executed once.
The loop may not execute if the The loop will always execute at least
condition is false initially. once, even if the condition is false.
Repeats the block of code only if the Repeats the block of code after the
condition is true. first run, then checks the condition.
This is Pre tested loop. This is post tested loop.
Q.3) Write algorithm showing the logic required to calculate and print the
sales tax on a purchase of four items.
1. Start
2. Initialize item1, item2, item3, item4 to store the prices of the four
items.
3. Initialize sales_tax_rate to store the sales tax percentage (e.g., 10% or
0.10).
4. Input prices for item1, item2, item3, and item4.
PREPARED BY: MUHAMMAD ABSAR KHAN CONTACT US: 0319-3578201
5|Page
5. Calculate the total price of the four items:
6. total_price = item1 + item2 + item3 + item4
7. Calculate the sales tax:
8. sales_tax = total_price * sales_tax_rate
9. Calculate the total amount to pay:
10. total_amount = total_price + sales_tax
11. Output the sales_tax.
12. Output the total_amount.
13. End
Q.4) What are the various symbols used in flowcharting? Give their
pictorial representation.
SYMBOLS DESCRIPTION
It is oval shape and is used to
show the start and end of a
Start/Stop
program or flow chart
sequence.
The arrow shape shows the
Arrows direction of flow from one step
or box to another.
This rectangle shape indicates
any type of internal operation
Process or process usually one step.
The step is written inside the
box .
This parallelogram shape
shows the output or input
process. It is used for any
Input/Output input/output operation and
indicates that the computer is
to obtain data or output
results.
This diamond shape shows
Decision/Condition decision based on a condition
written in the diamond.
PREPARED BY: MUHAMMAD ABSAR KHAN CONTACT US: 0319-3578201
6|Page
A small circle shape used to
connect different sections of a
Connector flowchart. It helps to avoid
long arrows and indicates flow
from one part to another.
Q.5) Why are there standards for the symbols used in drawing flowcharts?
Clarity and Consistency:
Standard symbols ensure that everyone understands a flowchart in the
same way, no matter who draws or reads it. This consistency helps avoid
confusion when interpreting the steps in a process.
Universal Understanding:
With standard symbols, flowcharts can be understood globally, across
different industries and regions. They create a common language for
representing processes, which is essential in business, software
development, engineering, and more.
Efficient Communication:
Flowcharts are often used in teams or organizations to communicate
complex processes. Standard symbols make it quicker and easier for
everyone to grasp the details of the process without needing extra
explanations.
Ease of Learning:
When everyone uses the same symbols, it becomes easier for new
learners or team members to understand how to read or create
flowcharts. Standardized symbols simplify the learning curve.
Error Reduction: Using standard symbols minimizes the risk of
misinterpreting the flowchart, ensuring the process or algorithm is
communicated accurately and implemented correctly.
PREPARED BY: MUHAMMAD ABSAR KHAN CONTACT US: 0319-3578201
7|Page
Q.6) Discuss Flowchart and their types.
Flowchart:
A flowchart is a visual representation of the sequence of steps and
decisions needed to perform a process or task. Flowcharts help in
planning, understanding, and analyzing the logical flow of a process,
making them useful in programming, problem-solving, and decision-
making.
Types of Flowcharts:
There are several types of flowcharts some are given below:
Sequential Flowchart:
In a sequential flowchart, all the processes or tasks happen in a straight,
step-by-step manner. Each step is followed by the next without any
deviation or branching. This type of flowchart is simple and used for
processes that don’t involve decisions or loops.
Example: Cooking instructions, where each action is performed one after
the other in a fixed order.
Branch Flowchart:
A branch flowchart, also called a decision flowchart, includes decision
points where the flow can go in different directions depending on
conditions. Each branch leads to a different outcome based on the
decision made.
It is used in decision-making processes, such as error-checking in
programs or conditional processes in business.
Example:
A process where a program checks if a condition is true or false (like
checking a password), and based on the outcome, different actions are
performed.
PREPARED BY: MUHAMMAD ABSAR KHAN CONTACT US: 0319-3578201
8|Page
Loop Flowchart:
A loop flowchart shows a process where a specific set of steps is repeated
until a condition is met. The flow keeps returning to a decision or action
until the loop’s condition is satisfied.
It is used in programming loops like "WHILE" and "FOR" loops, where
certain instructions are repeated.
Example:
Checking if all items in a list have been processed. If not, the loop
continues until each item is handled.
Nested Loop Flowchart:
In a nested loop flowchart, one loop is placed inside another loop. This is
used for situations
where an inner process must be completed multiple times within an
outer repeating process.
It is commonly in more complex algorithms that involve nested iterations,
such as matrix calculations or multi-level decision-making processes.
Example:
Iterating through rows of a matrix where an inner loop processes the
elements of each row while the outer loop handles the rows.
Q.7) Write algorithm of following problem.
ALGORITHM 1: SUM OF TWO NUMBERS
• Step#1 Start
• Step#2 Declare variables num 1, num 2 and sum
• Step#3 Read values num 1 and num 2
• Step#4 add num 1 and num 2 and assign the result to sum
Sum=num1+num2
• Step#5 Display sum
• Step#6 Stop
PREPARED BY: MUHAMMAD ABSAR KHAN CONTACT US: 0319-3578201
9|Page
ALGORITHM 2: AVERAGE OF THREE NUMBERS
• Step#1 Start
• Step#2 Declare variables num 1,num 2, num 3, and average
• Step#3 Read values num 1, num 2 num 3
• Step#4 Apply formula ( Average=Sum/no. of values)
Avg = (num 1+num 2 num 3)
• Step#5 Display average
• Step#6 Stop
ALGORITHM 3: VOLUME OF BOX
• Step#1 Start
• Step#2 Declare variables length, width and height
• Step#3 Read values length, width and height
• Step#4 Apply formula (volume=lengthxwidthxheight)
Volume=lengthxwidthxheight
• Step#5 Display volume
• Step#6 Stop
ALGORITHM 3: PERIMETER OF CIRCLE
• Step#1 Start
• Step#2 Declare variables radius and perimeter
• Step#3 Read the value of radius
• Step#4 Apply the formula perimeter = 2 × π × radius
• Step#5 Display the value of perimeter
• Step#6 Stop
PREPARED BY: MUHAMMAD ABSAR KHAN CONTACT US: 0319-3578201
10 | P a g e
Q.8) Discuss the function of FOR loop with example.
This loop executes a sequence of statements multiple times. It is usually
used in situations where at the start of loop we know that how many
times loop block will execute. It is a pre-test loop as condition is tested at
the start of loop. It starts with keyword "for" followed by loop expression in
parenthesis.
For Example:
#include <stdio.h>
int main() {
int n = 10; // You can change 'n' to any number of iterations you want
for (int i = 0; i < n; i++)
{
printf("%d ", i);
}
printf("\n");
return 0;
}
Q.10) Discuss Loop and their types with example.
LOOP:
In Computer Programming, a Loop is the sequence of instructions that is
repeated until a certain condition is reached. Loops are essential for
executing repetitive tasks efficiently.
Types of Loops:
There are several types of loops, but the most common ones are:
1. For Loop
2. While Loop
3. Do While Loop
For Loop:
PREPARED BY: MUHAMMAD ABSAR KHAN CONTACT US: 0319-3578201
11 | P a g e
This loop execute a sequence of statement multiple times. It is usually
used in situations where at the start of loop we know that how many
times loop block will execute. It is a pre-test loop as condition is tested at
the start of loop.
It starts with keyword "for" followed by loop expression in parenthesis.
Loop expression has three parts separated by semicolon. loops variable
and third part in increment or decrement in loop variable. Then comes the
body of the loop which may have one or more statements. If there are
more than one statements then they are enclosed in braces.
For Example:
#include <stdio.h>
int main() {
for (int i = 0; i < 5; i++) {
printf("Iteration: %d\n", i);
}
return 0;
}
While Loop:
It is a pre-test loop. It tests the condition at the start of loop before
executing the body of loop. It is usually used in situations where we do not
know at the start of loop, how many times loop block will execute. So, it is
also called indefinite repetition loop. It starts with keyword "while"
followed by a conditional expression like if statement in parenthesis. Then
comes the body of the loop which may have one or more statement in
braces
For Example:
#include <stdio.h>
int main() {
int i = 0;
while (i < 5) {
printf("Iteration: %d\n", i);
i++;
}
return 0;
}
PREPARED BY: MUHAMMAD ABSAR KHAN CONTACT US: 0319-3578201
12 | P a g e
Do While Loop:
It is similar to while loop, except that it tests the condition at the end of
the loop body and so it is also called post-test loop. Its statements block is
executed at least once. it guarantees that the block of code will be
executed at least once, even if the condition is false.
For Example:
#include <stdio.h>
int main() {
int i = 0;
do {
printf("Iteration: %d\n", i);
i++;
} while (i < 5);
return 0;
}
Q.10) Discuss the advantages of flowcharts
Advantages of Flowcharts:
Clarity and Simplification:
Flowcharts visually represent complex processes, making them easy to
understand. They break down steps and decisions, simplifying the overall
structure of a task or problem.
Improved Communication:
Flowcharts use universally recognizable symbols, which makes them an
effective tool for communicating processes across teams, departments, or
individuals, regardless of technical expertise.
Problem Solving:
By visualizing a process, flowcharts help in identifying potential
bottlenecks, errors, or inefficiencies. This makes troubleshooting and
problem-solving easier.
Efficient Documentation:
Flowcharts provide clear documentation of processes and systems, which
is useful for training, audits, and process improvements.
PREPARED BY: MUHAMMAD ABSAR KHAN CONTACT US: 0319-3578201
13 | P a g e
Better Planning and Organization:
Flowcharts assist in organizing thoughts, ideas, and steps, making them
ideal for project planning, workflow design, and system development.
Facilitates Debugging and Maintenance:
In software development, flowcharts help in understanding program logic,
making debugging and future maintenance simpler and faster.
Q.11) Write the rules for making Flowcharts.
1. Use standard symbols (Oval, Rectangle, Diamond, Arrows).
2. Flow from top to bottom or left to right.
3. Ensure one entry and one exit for each symbol.
4. Keep it simple and avoid over complication.
5. Use proper spacing between symbols.
6. Label each step with clear, descriptive text.
7. Use directional arrows to show flow.
8. Avoid crossing flow lines or use bridges for clarity.
9. Decision points must have at least two paths (e.g., Yes/No).
10. Maintain consistency in symbols, spacing, and labels throughout.
PREPARED BY: MUHAMMAD ABSAR KHAN CONTACT US: 0319-3578201