1. Write an algorithm to calculate sum of two numbers.
2. Write an algorithm to calculate area of rectangle.
3. Write an algorithm to calculate area of circle.
4. Shopkeeper sells mangos @ 10 Rs/mango a customer buys 5 mangoes from shop keeper, write an algorithm to calculate bill
4. Shopkeeper sells mangos @ 10 Rs/mango, write an algorithm to calculate bill
Swapping of two number
Swapping using 3 variables
Algorithm
Flowchart
Swapping without using third variable (+, - operator)
Algorithm
Flowchart
Swapping without using third variable (*, / operator)
Algorithm
Flowchart
Check whether any positive number is single digit or multi digit.
Algorithm
step 1 : start
step 2 : input n
step 3 : if n ≤ 9
print number is single digit
else
print number is multi digit
step 4 : stop
Flowchart
Check whether a number is even or odd.
Algorithm
step 1 : start
step 2 : input n
step 3 : if n % 2 == 0
print n is even
else
print n is odd
step 4 : stop
Flowchart
Check whether any number is positive, negative or zero
Algorithm
step 1 : start
step 2 : input n
step 3 : if (n < 0)
print n is negative number
else if (n > 0)
print n is positive number
else
print n is zero
step 4 : stop
Flowchart
(Assignment) Input 4 marks of subject and calculate percentage
and make result according to following
percentage >= 70 → 1st division with honours
60 <= percentage <= 70 → 1st division
50 <= percentage <= 60 → second division
40 <= percentage <= 50 → third division
percentage < 40 → failed
Algorithm
step 1 : start
step 2 : input m1, m2, m3 & m4
step 3 : percentage = (m1 + m2 + m3 + m4)/4
step 4 : if (percentage >= 70)
print 1st division with honours
else if (percentage >= 60)
print 1st division
else if (percentage >= 50)
print 2nd division
else if (percentage >=40)
print 3rd division
else
print failed
step 5 : stop
Flowchart
Print first 10 natural numbers
Algorithm
step 1 : start
step 2 : n = 1 // initialization
step 3 : repeat step 4 while (n ≤ 10) // condition
step 4 : print n
n = n + 1 // updation
step 5 : stop
Flowchart
Print first n natural numbers
Algorithm
step 1 : start
step 2 : input num
step 3 : n = 1
step 4 : repeat step 5 while (n ≤ num)
step 5 : print n
n = n + 1
step 6 : stop
Flowchart
Print sum of first n natural numbers
Algorithm
step 1 : start
step 2 : input n
step 3 : sum = 0, c = 1
step 4 : repeat step 5 while (c ≤ n)
step 5 : sum = sum + c
c = c + 1
step 6 : print sum
step 7 : stop
Flowchart
Print factorial of a given number
Algorithm
step 1 : start
step 2 : input n
step 3 : fact = 1, c = 1
step 4 : repeat step 5 while (c ≤ n)
step 5 : fact = fact * c
c = c + 1
step 6 : print fact
step 7 : stop
Flowchart
Factorial of a number the right way ↓
Print factorial of a given number
Algorithm
step 1 : start
step 2 : input n
step 3 : fact = 1, c = n
step 4 : repeat step 5 while (c ≥ 1)
step 5 : fact = fact * c
c = c - 1
step 6 : print fact
step 7 : stop
Flowchart
Print factorial of a given number using 'for loop'
Flowchart
Print factorial of a given number using 'for loop' (decrement)
Flowchart