Question: This assignment is mainly to practice the Selection programming structure. That is IF ... THEN ... ELSE ... END IF and IF ... THEN ...

This assignment is mainly to practice the Selection programming structure.

That is IF ... THEN ... ELSE ... END IF and IF ... THEN ... ELSEIF ... ELSEIF .... END IF

What is the output of the following codes, consider each case indecently:

Case 1. Assume i = 1 and HowMuch = 0

IF i < 5 THEN HowMuch = HowMuch + 1

ELSEIF i = 5

THEN HowMuch = HowMuch - 5

ELSE HowMuch = HowMuch + 3

END IF

DISPLAY HowMuch

Case 2. Assume i = 5 and HowMuch = 0

IF i < 5 THEN HowMuch = HowMuch + 1

ELSEIF i = 5

THEN HowMuch = HowMuch - 5 ELSE HowMuch = HowMuch + 3

END IF

DISPLAY HowMuch

Case 3. Assume i = 6 and HowMuch = 0

IF i < 5

THEN HowMuch = HowMuch + 1 ELSEIF i = 5

THEN HowMuch = HowMuch - 5

ELSE HowMuch = HowMuch + 3

END IF

DISPLAY HowMuch

2. Use the following selection structure to answer the next three questions:

If intNumber<= 100 Then intNumber = intNumber * 2 ElseIf intNumber> 500

Then intNumber = intNumber * 3

End If

2a) Assume intNumber initially contains 50.

What value intNumber will contain after the above selection structure is executed?

2b) Assume intNumber initially contains 500.

What value intNumber will contain after the above selection structure is executed?

2c)Assume intNumber initially contains 1000.

What value intNumber will contain after the above selection structure is executed?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!