Worksheets - 1
Assignment and conditional operators
Assignment operator
1. 2. 3. 4. 5.
a 10 x5 num 8 x 10 x 10
ba xx*2 num num / 2 y5 y5
aa+5 xx-3 num num + 3 xx+y*2 xx+y*2
OUTPUT num yx-y OUTPUT x
OUTPUT y
Conditional operator (IF..THEN..ELSE..ENDIF)
Basic formula: 1. Write a pseudocode to accept two integers and check whether they are
equal or not.
IF condition
THEN OUTPUT “Enter 2 numbers”
INPUT num1, num2
OUTPUT something IF num1 = num2
THEN
ELSE OUTPUT “Equal numbers”
ELSE
OUTPUT something OUTPUT “Not equal”
ENDIF
ENDIF
Conditional operator (IF..THEN..ELSE..ENDIF)
Basic formula: 2. Write a pseudocode to check whether a given number is even or odd.
IF condition
THEN OUTPUT “Enter a number”
INPUT num1
OUTPUT something IF num1 % 2 = 0
THEN
ELSE OUTPUT “Even number”
ELSE
OUTPUT something OUTPUT “Odd number”
ENDIF
ENDIF
Conditional operator (IF..THEN..ELSE..ENDIF)
Basic formula: 3. Write a pseudocode to check whether a given number is positive or negative.
IF condition
THEN OUTPUT “Enter a number”
INPUT num1
OUTPUT something IF num1>0
THEN
ELSE OUTPUT “Positive number”
ELSE
OUTPUT something OUTPUT “Negative number”
ENDIF
ENDIF