0% found this document useful (0 votes)
38 views2 pages

02 - Practice Questions of Selection

Pseudo code is an informal language that helps programmers develop algorithms. It uses a textual format and indentation to illustrate program logic and flow. Examples show how to write if-else statements to check conditions and output different results accordingly. The document then provides a list of practice problems involving two-way if statements, one-way if statements, and if statements using logical operators like && and ||. The problems involve getting input from the user and conditionally printing outputs based on the input values.

Uploaded by

spideyxd1122
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views2 pages

02 - Practice Questions of Selection

Pseudo code is an informal language that helps programmers develop algorithms. It uses a textual format and indentation to illustrate program logic and flow. Examples show how to write if-else statements to check conditions and output different results accordingly. The document then provides a list of practice problems involving two-way if statements, one-way if statements, and if statements using logical operators like && and ||. The problems involve getting input from the user and conditionally printing outputs based on the input values.

Uploaded by

spideyxd1122
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Programming Fundamental

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:

If (student's grade >= 60)


Print "passed"
Else
Print "failed"
End If

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. Write a program that gives absolute of a number input by user.


2. Write a program that requests an integer value representing the month of the year and gives the number of days
in that month.
3. Write a program that reads a single digit value (0-9) and then prints the number as a literal string. For example, if
input is 7, then the output should be word “seven”.
4. Write a program that takes a point (x, y) from the user and find where does the point lies.

Hassan Khan, PUCIT – PU. Page 1 of 2


Programming Fundamental

JOINING CONDITIONS using && and ||

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   

Hassan Khan, PUCIT – PU. Page 2 of 2

You might also like