Algorithms and Flowcharts

This page contains the CBSE class 11 Computer Science with Python chapter 1, Algorithms and Flowcharts. You can find the questions/answers/solutions for the chapter 1 of Unit 2 of CBSE class 11 Computer Science with Python in this page.
Multiple Choice Questions
1. A step by step method for solving a problem using English Language
(a)
program
(b)
Flowchart
(c)
statement
(d)
Algorithm ✔
2. Set of statements is executed based upon conditional test.
(a)
Looping
(b)
Selective ✔
(c)
Sequence
(d)
None
3. Set of statements is executed again and again based upon conditional test.
(a)
Looping ✔
(b)
Selective
(c)
Sequence
(d)
None
4. The graphical representation of algorithm is
(a)
program
(b)
Flowchart ✔
(c)
statement
(d)
Algorithm
5. All instructions are executed one after other.
(a)
Looping
(b)
Selective
(c)
Sequence ✔
(d)
None
Answer the following questions.
1. Define Algorithm.
An algorithm is a step-by-step procedure or a set of rules for solving a specific problem or accomplishing a particular task. In computing, algorithms form the backbone of program design, and they are written in pseudocode or a flowchart before being implemented in a specific programming language.
2. Define Flowchart.
A flowchart is a graphical representation of an algorithm or a process. It uses different shapes and symbols to denote different types of instructions or paths. It helps in understanding the logical sequence and the control flow of the algorithm.
3. Write an algorithm to find the sum of two numbers.
The following is the algorithm to find the sum of two numbers.
Step 1:
Start
Step 2:
Take the two numbers and store them as A and B
Step 3:
Add A and B and store them as Sum
Step 4:
Print the Sum
Step 5:
Stop
4. Write an algorithm to find the area of a triangle.
The following is the algorithm to find the area of a triangle.
Step 1:
Start
Step 2:
Take base and height and store them as B and H?
Step 3:
Find the area using {\text{area} = \dfrac{1}{2} × \text{B} × \text{H}}
Step 4:
Print area
Step 5:
Stop
5. Write an algorithm to find whether given number is odd or even.
The following is the algorithm to find whether a given number is odd or even.
Step 1:
Start
Step 2:
Input number N
Step 3:
Check N modulo 2 (or N % 2 = 0). If it is equals 0, then goto Step 4, Otherwise go to Step 5.
Step 4:
Print “even” and go to Step 6
Step 5:
Print “odd”
Step 6:
Stop
6. Write an algorithm to find the sum of all even numbers up to given number.
The following is the algorithm to find the sum of all even numbers up to given number.
Method 1: Consider all the numbers upto the given number by incrementing each by 1.
Step 1:
Start
Step 2:
Take any number and store it in N.
Step 3:
Store 0 in I and store 0 in Sum.
Step 4:
Find I modulus 2 (or I % 2). If I modulus 2 equals 0 Go To Step 5, Otherwise Go To Step 6
Step 5:
Add I to Sum.
Step 6:
Increment I by 1
Step 7:
If I ≤ N Go To Step 4. Otherwise Go To Step 8
Step 8:
Stop
Method 2: Consider all the even numbers upto the given number by incrementing each by 2.
Step 1:
Start
Step 2:
Take any number and store it in N.
Step 3:
Store 0 in I and store 0 in Sum.
Step 4:
Add I to Sum
Step 5:
Increment I by 2
Step 6:
If I ≤ N Go To Step 4. Otherwise Go To Step 7
Step 7:
Stop
7. Draw a flowchart to find the area of a circle.
The following is the flowchart to find the area of a circle.
Flowchart to find the area of a circle. Start Read the radius as input Calculate the area of the circle using the formula A = πR² Print the Area of the circle calculated above. Stop Start Stop Input Radius (R) Area = πR² Print Area

Flow Chart to find the area of circle.
9 8. Draw a flowchart to find the smallest number among n numbers.
The following is the flowchart to find the smallest number among n numbers.
Flowchart to find the smallest number among n numbers. Start Input the number of numbers that we need to check and assign it to n Take the first number and assign it to A Initialize I as 1 and assign Small as A Check whether I less than or equal to n If I less than or equal to n (i.e. we’ve not completed all the numbers yet), take the next number and assign it to A Is Small greater than A? Small is greater than A. So, Small is not small. In otherwords A is the new small. So, assign A to Small. Increment I by 1 so that we can go to the next number (It’ll be checked against n in the next step, which is iterative). I is not less than n. In otherwords, we have read all the n numbers. So, it is time to print final ‘Small’. Print Small Stop Start Stop Input n Input A I = 1 Small = A Is I ≤ n Input A Yes Is Small > A? Yes No Small = A I = I + 1

No Print Small

Flow Chart to find the smallest number among n numbers.
10. 9. Draw a flowchart to find the sum of all multiples of 5 up to given number.
The following is the flowchart to find the sum of all multiples of 5 up to a given number n numbers.
Flowchart to find the sum of all the multiples of 5 up to a given number. Start Input the number of numbers that we need to check and assign it to n Initialize I as 1 and Sum = 0 Check whether I less than or equal to n If I less than or equal to n, check whether I is multiple of 5? As I is multiple of 5, add I to Sum. Increment I by 1. I is not less than n. In otherwords, we have added all the multiples of 5 upto. So, it is time to print final ‘Sum’. Print Sum Stop Start Stop Input n I = 1 Sum = 0 Is I ≤ n Yes Is I multiple of 5? Yes Sum = Sum + I I = I + 1 No Print Sum No

Flow Chart to find the sum of all multiples of 5 up to a given number n numbers.
11 10. Mona is confused about finite loop and infinite loop, explain her with the help of example.
Finite loop is a loop that executes a specific number of times. For example, printing numbers from 1 to 10.
In contrast, an infinite loop is a loop that continues indefinitely because
it lacks a functional incremental statement
or a proper condition to terminate it.
For example, a loop that keeps printing “Hello” without any condition to stop it.
12 11. Write an algorithm and a flowchart to find sum of n numbers.
Note: It is not specified in the problem whether we need to find the sum of n natural numbers or n different numbers. So, we’ve provided below flowcharts for both the cases.
1. a) Algorithm to find the sum of n natural numbers:
Step 1:
Start
Step 2:
Input number N
Step 3:
Initialize I as 1 and Sum as 0
Step 4:
Check whether I is less than or equal to N. If Yes, Go to Step step 5, Otherwise Go to Step 7.
Step 5:
Add I to Sum..
Step 6:
Increment I by 1. Go to Step 4
Step 7:
Print Sum
Step 8:
Stop
1. b) Flowchart to find the sum of n natural numbers.
Flowchart to find the sum of n natural numbers. Start Input the number of numbers that we need to check and assign it to n Initialize I as 1 and assign Small as A Check whether I less than or equal to n I is less than n. So, I to Sum. Increment I by 1 so that we can go to the next number (It’ll be checked against n in the next step, which is iterative). I is not less than n. In otherwords, we have read all the n numbers. So, it is time to print final ‘Sum’. Print Sum Stop Start Stop Input n I = 1 Sum = 0 Is I ≤ n Sum = Sum + I Yes I = I + 1 No Print Sum

Flow Chart to find the sum of n natural numbers.
2. a) Algorithm to find the sum of n numbers:
Step 1:
Start
Step 2:
Input number N
Step 3:
Initialize I as 1 and Sum as 0
Step 4:
Check whether I is less than or equal to N. If Yes, Go to Step step 5, Otherwise Go to Step 8.
Step 5:
Input number A
Step 6:
Add A to Sum..
Step 7:
Increment I by 1. Go to Step 4
Step 8:
Print Sum
Step 9:
Stop
2. b) Flowchart to find the sum of n numbers.
Flowchart to find the sum of n natural numbers. Start Input the number of numbers that we need to check and assign it to n Initialize I as 1 and assign Small as A Check whether I less than or equal to n I is not less than n. So, let’s take the number to add as Input. Assign it to A Add A to Sum. Increment I by 1 so that we can go to the next number (It’ll be checked against n in the next step, which is iterative). I is not less than n. In otherwords, we have read all the n numbers. So, it is time to print final ‘Sum’. Print Sum Stop Start Stop Input n I = 1 Sum = 0 Is I ≤ n Yes Input A Sum = Sum + A I = I + 1 No Print Sum

Flow Chart to find the sum of n numbers.