0% found this document useful (0 votes)
2 views5 pages

Assignment and Conditional Operators Guide

Uploaded by

boomexploder.com
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)
2 views5 pages

Assignment and Conditional Operators Guide

Uploaded by

boomexploder.com
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

Worksheets - 1

Assignment and conditional operators


Assignment operator

1. 2. 3. 4. 5.

a  10 x5 num  8 x  10 x  10
ba xx*2 num  num / 2 y5 y5
aa+5 xx-3 num  num + 3 xx+y*2 xx+y*2
OUTPUT num yx-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

You might also like