You are on page 1of 14

MIDTERM

Prepared By:
CAMANSAG, HONEY PEARL B.
19-01855
EE-1204
1. IF-THEN STATEMENT
PROGRAM CODE LOGIC/PROCESS WITHIN OUTPUT

Start of program execution


a=1234567
b=89123456

Start of IF statement
Is a<b?
TRUE

Therefore, the statement under “if(a<b)” then


the display the value of ‘b’ which is 89123456
followed by “is larger.”

Exit IF statement

End of program
2. IF-THEN STATEMENT
PROGRAM CODE LOGIC/PROCESS WITHIN OUTPUT

Start of program execution


num==10

Start of IF-THEN statement


Is num==1?
FALSE
Therefore, skip the statement with
“if(num==1)then proceed to next statement.

Is num==2?
FALSE
Therefore, skip the statement with
“if(num==2)then proceed to next statement.

Is num==3?
FALSE
Therefore, skip the statement with
“if(num==3)then proceed to next statement

Is num==4?
FALSE
Therefore, skip the statement with
“if(num==4)then proceed to next statement
2. IF-THEN STATEMENT
PROGRAM CODE LOGIC/PROCESS WITHIN OUTPUT

Is num==5?
FALSE
Therefore, skip the statement with
“if(num==5)then proceed to next statement

Is num==6?
FALSE
Therefore, skip the statement with
“if(num==6)then proceed to next statement

Is num==7?
FALSE
Therefore, skip the statement with
“if(num==7)then proceed to next statement

Is num==8?
FALSE
Therefore, skip the statement with
“if(num==8)then proceed to next statement
2. IF-THEN STATEMENT
PROGRAM CODE LOGIC/PROCESS WITHIN OUTPUT

Is num==9?
FALSE
Therefore, skip the statement with
“if(num==9)then proceed to next statement

Is num==10?
TRUE
Do the statement under case 10
Display “October”

Exit IF statement

End of program
A. IF-ELSE STATEMENT
PROGRAM CODE LOGIC/PROCESS WITHIN OUTPUT

Start of program execution


Num=1506

Start of IF statement
Is 1506 is Even?
True

Therefore, the statement under if (num


%2==0) then the display the given number
which is 1506 followed by “EVEN and ODD.”

Exit IF statement

End of program
B. IF-ELSE STATEMENT
PROGRAM CODE LOGIC/PROCESS WITHIN OUTPUT

Start of program execution


Num=1220

Start of IF statement
Is 1220 Positive?
True

Therefore, the statement under “if (num>0)”


then the display the given value or numbers
which is 1220 followed by “positive and
negative.”

Exit IF statement

End of program
2. IF-ELSE STATEMENT
PROGRAM CODE LOGIC/PROCESS WITHIN OUTPUT

Start of program execution


num=82

Start of IF statement
Is 82 is?
TRUE

Therefore, the statement under “if(a<b)” then


the display the value of ‘b’ which is 89123456
followed by “is larger.”

Exit IF statement

End of program
3. IF-ELSE STATEMENT
PROGRAM CODE LOGIC/PROCESS WITHIN OUTPUT

Start of program execution


Num=20

Start of IF statement
Is age 20 is qualified?
True

Therefore, the is statement under “int age;”


then the display your age which is 20
followed by “Qualified Voter.”

Exit IF statement

End of program
1. SWITCH STATEMENT
PROGRAM CODE LOGIC/PROCESS WITHIN OUTPUT

Start of program execution


num==3

Start of SWITCH statement


Is num==1?
False
Therefore, skip statement under case 1 then
proceed to next statement.

Is num==2?
False
Therefore, skip statement under case 2 then
proceed to next statement
Exit IF statement

Is num==3?
True
Do the statement under case 3
Display “March”

Exit SWITCH Statement

End of program
2. SWITCH STATEMENT
PROGRAM CODE LOGIC/PROCESS WITHIN OUTPUT

Start of Program
a=10
b=15

Start of switch
Is num==1?
TRUE
Do the statement under case 1
Display “Addition”

Exit SWITCH Statement

End of Program
2. SWITCH STATEMENT
PROGRAM CODE LOGIC/PROCESS WITHIN OUTPUT
3. SWITCH STATEMENT
PROGRAM CODE LOGIC/PROCESS WITHIN OUTPUT

Start of Program
Num=3

Start of switch
Is num==1?
False
Therefore, skip statement under case 1 then
proceed to next case.

Is num==2?
False
Therefore, skip statement under case 1 then
proceed to next case.

Is num==3?
True
Do the statement under case 3
Display “Pizza”

Exit SWITCH Statement

End of Program

You might also like