Page 58 - CloudGPT_C7_Flipbook
P. 58
If there is another if-else construct within the if block or the else block, this is called nesting
or nested if-else.
Interdisciplinary
Example 1: To check if a number is divisible by 2 or 3 or by both 2 and 3.
Solution:
You first need an IF condition to check if the number is divisible by 2 or not. Within the IF
condition, you can implement another IF condition to check if the given number is divisible by
3 or not. Using this method you can check if the number is divisible by 2 or by both 2 and 3.
Coding Task 03 Subject Enrichment
The remainder problem
In this task, you will check if a number is divisible by 2 or 3 or both 2 and 3 by using 'nested
conditional statement' in MakeCode.
To perform the task, follow these steps:
Step 1: Open MakeCode, click on 'New Project'. Write the name of project 'remainder
problem', and click on 'Create'.
Step 2: Click on 'Variables', select 'Make a Variable', write the name of the variable as
'Number', then click on 'OK'. Variable 'Number' will appear in 'Make a Variable…'.
Step 3: Drag the 'Set Number to block' to workspace area, and change its value to 10.
After that drop the 'Set Number' block to 'on start' block.
56 Premium Edition-VII

