Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Programming homework 2

Question 1:
Design a program that inputs a number and displays High if the number is greater
than 10 and displays Low otherwise
DECLARE num1: Integer
PRINT "Please enter a number"
INPUT num1
IF num1>10
THEN PRINT "High"
ELSE PRINT "Low"
ENDIF

Question 2:
Design a program that inputs a package weight in kg. The program should display
Heavy if the weight is greater than or equal to 20 and display Light otherwise.
DECLARE weight1: REAL
PRINT "please enter the weight of the package in kg"
INPUT weight1
IF weight1>=20
THEN PRINT "Heavy"
ELSE PRINT "Light"
ENDIF
Question 3:
Design a program that inputs two numbers from the user and outputs the bigger
one.
DECLARE num1, num2: INTEGER
PRINT "Please enter two numbers"
INPUT num1, num2
IF num1>num2
THEN PRINT num1, " is the bigger number"
ELSE IF num2>num1
THEN PRINT num2," is the bigger number"
ELSE PRINT "Both numbers are equal."
ENDIF
ENDIF

Question 4:
Design a program that inputs a password (twice) and then confirms this password
and displays Passwords Match if the two passwords are equal and displays
Passwords are different otherwise
DECLARE pass1, pass2: STRING
PRINT "Please enter your password"
INPUT pass1
PRINT "re-enter your password for confirmation"
INPUT pass2
IF pass1=pass2
THEN PRINT "Passwords Match"
ELSE PRINT "Passwords are different"
ENDIF
Question 5:
Design a program that takes the length of a side of a square and the program
outputs the perimeter of the square.

Perimeter of the square = Side * 4

Display Invalid if the side length is zero or less

DECLARE side1, per: REAL


PRINT "please enter the length of side of the square"
INPUT side1
per<-side1*4
IF side1<=0
THEN PRINT" invalide length"
ELSE PRINT "the perimeter is ", per
ENDIF

You might also like