Page 60 - Touchcode_C6_Flipbook
P. 60
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 to' block to 'on start' block.
58 Touchcode-VI

