Examples
1.Write an algorithm to print a welcome message.
Solution - The desired algorithm to print the welcome message is given as follows:
Steps:
- Start
- Print “Welcome to India”
- Stop
2.Write an algorithm to print your name.
Solution - The desired algorithm to print your name is given as follows:
Steps:
- Start
- Print “My name is Yash”
- Stop
3.Write an algorithm to print any numeric value using the variable. (Use Assignment operator)
Solution - The desired algorithm to any numeric value using the variable is given as follows:
Steps:
- Start
- input A
- A → 10
- Print A
- Stop
4.Write an algorithm to find the sum of any two numbers. (Use Assignment operator)
Solution - The desired algorithm to find the sum of any two number is given as follows:
Steps:
- Start
- input A, B, C
- A → 10
- B → 05
- C ← A + B
- Print C
- Stop
5.Write an algorithm to find the multiplication of any two numbers. Use Assignment operator)
Solution - The desired algorithm to find the multiplication of any two number is given as follows:
Steps:
- Start
- input A, B, C
- A → 02
- B → 05
- C ← A * B
- Print C
- Stop
Solution - The desired algorithm for interchanging the numeric values of two variables given by the user is given as follows:
Steps:
- Start
- print "Enter first number"
- input A
- print "Enter second number"
- input B
- T = A
- A = B
- B = A
- C ← A * B
- Print A, B
- Stop
Solution - The desired algorithm to find the given number is positive or not is given as follows:
Steps:
- Start
- input A
- A → 5
- if
- (A > 0) then
- print "Given number is positive"
- else
- print "Given number is not positive"
- Stop
Solution - The desired algorithm to check whether the student is pass or not is given as follows:
Steps:
- Start
- input SM
- SM → 50
- if
- (SM > 33 ) then
- print "Pass"
- else
- print "Fail"
- Stop
Solution - The desired algorithm that compares two numbers and prints the message identifying the greater number is given as follows:
Steps:
- Start
- input A, B
- A → 20
- B → 21
- if
- (A > B) then
- print "A is greater number"
- else
- print "B is greater number"
- Stop
Solution - The desired algorithm to check whether a number given by the user is odd or even is given as follows:
Steps:
- Start
- print "Enter first number"
- input A
- if
- (A%2=0 ) then
- print "Number is even"
- else
- print "NUmber is odd"
- Stop
Solution - The desired algorithm to print largest number among three numbers. (use logical operator) is given as follows:
Steps:
- Start
- input A, B, C
- A → 50
- B → 54
- C → 23
- if
- (A > B AND A > C)
- print "A is largest number"
- else if (B > A AND B > C)
- print "B is largest number"
- else
- print "C is largest number"
- Stop
Solution - The desired algorithm to find the addition of N-given numbers is given as follows:
Steps:
- Start
- input C
- while C < = 40
- Begin
- Print C
- C ← C + 1
- End
- Stop
0 Comments