02 - Practice Questions of Selection
02 - Practice Questions of Selection
P s e u d o C o d e - S e l e c t i o n
Practice Questions
Pseudo code is an artificial and informal language that helps programmers develops algorithms. Pseudo code is a "text-
based" detail (algorithmic) design tool.
The rules of Pseudo code are reasonably straightforward. All statements showing "dependency" are to be indented. These include
while, do, for, if, switch. Examples below will illustrate this notion.
EXAMPLE:
Problem List
TWO-WAY IF
1. Write an if-else statement that outputs the word “High” if the value of the variable score is greater than 100, and
“Low” if the value of score is at most 100.
2. Write a program that gets a number from user, if it is negative then display “The number is negative” otherwise,
display “The number is non-negative”.
3. Prompt the user for two numbers A & B, computes and displays C=A/B. If the number B is zero, displays a “division
by Zero” message.
4. Write a program to input age and print if the age is valid enough to have a driving license.
5. Input two positive numbers from user and display the maximum out of them.
6. Three numbers denoted by the variables A, B and C are supplied as input data. Identify and print the largest one of
these numbers.
7. Write a program that reads an integer and determines and prints whether it is odd or even. (Hint: First use the
simple division, then introduce modulus operator).
8. Write a program that reads two integers (in any order) and then print either “multiple” or “not” according to
weather 2nd number is multiple of the 1st one or not.
ONE-WAY IF
1. Input a number form the user, if it is between 1 and 100, display “In Range” otherwise display “Out of Range”.
2. Write a program that inputs a number and displays its number of digits. Assume that user will enter a positive number less
than 1000.
3. Write an if-else statement that outputs the word “Warning” provided that either the value of the variable temperature is
greater than or equal to 100, or the value of the variable pressure is greater than or equal to 200, or both. Otherwise, the if-
else statement outputs the work “OK”.
4. Input marks from a user, if marks are greater than 85 display “Excellent”, if the marks are between 80 and 84 (both inclusive)
display “Very Good”, if the marks are between 75 and 79 (both inclusive) display “Good”, if the marks are between 70 and 74
(both inclusive) display “Fair”, if the marks are between 65 and 69 (both inclusive) display “Satisfactory”, otherwise display
“You may not get the degree with such marks”.
5. Write a program that takes a point (x, y) from the user and find where does the point lies.
BEST OF LUCK