Ex 1. Write an algorithm to check whether a given number is even or odd.
Step 1: Start
Step 2: Declare variables n.
Step 3: Read value of n.
Step 4: check if n is divisible by 2 go to step 5
else go to step 6
Step 5: print n is even number go to step 7
Step 6: print n is odd number
Step 7: Stop
Ex 2: Write an algorithm to find large number among given two numbers.
Step 1: Start
Step 2: Declare variables num1, num2
Step 3: Read values num1 and num2.
Step 4: Check if num1 is greater than num2 go to step 5
else go to step 6
Step 5: Display num1 is greater go to step7
Step 6: Display num2 is greater
Step 7: Stop
Ex 3. Write an algorithm to find the largest among three different numbers
entered by user.
Step 1: Start
Step 2: Declare variables a,b and c.
Step 3: Read variables a,b and c.
Step 4: Check if a>b go to step5
else go to step 8
Step5: Check if a>c go to step6
else go to step 7
Step6: Print a is greater step 10
step7: Print c is greater step 10
step8: check if b>c go to step 9
else go to step 7
step9: print b is greater
step10: stop
Ex4. Write an algorithm to f calculate simple interst
Step 1: Start
Step 2: Declare variables P,R,T,I
Step 3: Enter the values of P,R,T
Step 4: Multiply P,R,T and divide with 100
Step 5: Stores the value in I.
Step 6: Display I value
Step 6: Stop
Ex5: Write an algorithm to check whether a given number is prime.
step1: Start
step2: Declare the variables i, n, count
step3: Enter the n value
step4: Assign count value with 0
step5: Assign i value with 1
step 6: Check if i<=n go to step 7
else go to step10
step7: check if n is divisible by I go to step 8
else go to step9
step8: increase count value by 1
step9: increases i value by 1 go to step 6
step10: check if count is equals to 2 go to step 11
else go to step12
step 11: print given number is prime go to step13
step 12: print given number is not a prime
step 13: stop
Ex6. Write an algorithm to swap two number
Step 1 : Start
Step 2: Declare variables num1, num2,temp
Step 2 : Read num1, num2
Step 3 : temp = num1
Step 4 : num1 = num2
Step 5 : num2 = temp
Step6 : print num1, num2
Step7 : Stop
Ex 7: Write an algorithm to check whether a given year is leap year
Step 1 : Start
Step 2: Declare variable ‘year’
Step 3: Enter the value of year, store it in ‘year’
Step 4: check if year is divisible by 100, then go to step5
else go to step 6
Step 5: Check if year is divisible by 400, then go to step 7
else go to step 8
Step 6: Check if year is divisible by 4, go to step 7
else go to step 8
Step 7 : Print the given year is leap year, then go to step 9
Step 8: print the given yea is not a leap year
Step 9: Stop
Ex8: Write an algorithm to print first ‘n’ even numbers. (i.e. if the input value
is ‘5’ the output should be 2, 4, 6, 8, 10)
Step 1: Start
Step 2: Declare variables n, i, count
Step 3: Enter the value of n.
Step 4: Assign the i value by 1
Step 5: Assign the count value by 1
Step6: Check if count<=n go to step7
else go to step 11
Step7: check if i is divisible by 2 go to step8
else go to step 10
step8: Print i value
step9: increase count by 1
step10: increase i by 1 go to step 6
step11: stop
Ex9: Write an algorithm to find sum of ‘n’ natural numbers.
Step 1: Start
Step 2: Declare variables n, i, sum
Step 3: Enter the value of n.
Step 4: Assign the i value by1 1
Step 5: Assign the sum value by 0
Step6: Check if i<=n go to step7
else go to step 9
Step7: Add i value to sum and assign to sum //sum=sum+i
step8: increase i value with 1 go to step 6
step 9: print sum value
step11: stop
Ex10: Write an algorithm to find area of a circle.
Step1: Star
Step2: Declare the variables r, area,Pi
Step3: Enter the value of r
Step4: multiply r with r
Step5: multiply the value with Pi value
Step 5: Store the value in area
Step6: print area
Step7: Stop
Ex 11: Write an algorithm to print a multiplication table of a given number up
to 10 steps.
Step 1: Start
Step 2: Declare the variable n, i
Step 3: Enter the value of n
Step 4: Assign the i value with 1
Step 5: check if i<=10 go to step 6
else go to step 8
Step 6: print multiplication of n with i value //n*i
Step 7: increase i value with 1 go to step5
Step 8: Stop
Ex 12: Write an algorithm to reverse a three digit number. (i.e. if input
is “123” the output should be “321”).
Step 1: Start
Step 2: Declare the variables n, rem, reverse
Step 3: Enter the value of n
Step4: Assign reverse value with 0
Step 5: check if n!=0 go to step 6
else go to step 9
Step 6: rem=n%10
Step7: reverse=reverse*10+rem
Step8: n=n/10 go to step 5
Step 9: print reverse
Step 10: Stop
Ex 13: Write an algorithm to check whether a given number is
palindrome? ( a number is said to be palindrome if it can be read same
forward and backward. Ex. 121, 32123)
Step 1: Start
Step 2: Declare the variables n, rem, reverse,P
Step 3: Enter the value of n
Step 4: Assign reverse value with 0
Step 5: Store n value in P
Step 6: check if n!=0 go to step 7
else go to step 10
Step 7: rem=n%10
Step 8: reverse=reverse*10+rem
Step 9: n=n/10 go to step 6
Step 10: check if reverse is equal to P go to step 11
else go to step 12
Step 11: print given number is palindrome go to step 13
step 12: print given number is not a palindrome
Step 13: Stop
Ex 14: Write an algorithm to check whether a given number is
Armstrong.
(An Armstrong number of three digits is an integer such that the sum
of the cubes of its digits is equal to the number itself. For example,
371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371).
Step 1: Start
Step 2: Declare the variables n, rem,num,A
Step 3: Enter the value of n
Step4: Assign num value with 0
Step 5: Store n value in A
Step 6: check if n!=0 go to step 7
else go to step 10
Step 7: rem=n%10
Step 8: num=num+(rem*rem*rem)
Step9: n=n/10 go to step 6
Step 10: check if num equals to A go to step 11
else go to step 12
Step 11: print given number is Armstrong go to step 13
step 12: print given number is not a Armstrong
Step 13: Stop
Ex 15:Write an algorithm to find Fibonacci series of the given number
(The first two numbers in the Fibonacci sequence are either 1 and 1, or
0 and 1, depending on the chosen starting point of the sequence, and
each subsequent number is the sum of the previous two)
Step 1: Star
Step 2: Declare the variable n, f0, f1,I,fn
Step 3: Assign the value of f0 is 0, f1 is 1, I is 2
Step 4: print the values of f0, f1
Step 5: Check if i<=n go to step6
else go to step11
Step6: fn=f0+f1
Step 7: f0=f1
Step 8: f1=fn
Step 9: print the value of fn
Step 10: Increase the I value with 1 go to step 5
Step 11: Stop