Page 93 - Computer_Genius_v2.1_C7_flipbook
P. 93
Step 4 Attach print block in do portion of if-do block. Add input block inside it.
(By this step, if the condition is satisfied, it will print Even Number as Output.)
Step 5 Attach print block in else portion of if-do block. Add input block inside it.
(By this step, if the condition is not satisfied, it will print Odd Number as Output.)
Step 6 Click on Run button. Enter the integer in the output window. Click on Enter button. Then
the output will be shown on the output window.
Program to Find the Greatest Number
To create an AI Connect program to find the greatest number out of the three random numbers,
create a project. In this project, create a Basic Coding activity. Then follow the given steps:
Step 1 Go to the Variables category and click on the Create variable... block to create a variables.
(Create three variables a, b and c)
Drag and drop set a to block from Variables category. Add int block from Conversion
category inside this block. Then, add input with prompt block from Input category inside
int block.
Follow the same steps for variable b and c.
Step 2 Attach if-do block from Logic category. Click on setting button of if-do block and add two
else if block and one else block in if-do block.
Step 3 In if portion of if-do block add comparisons for the variables using logical and relational
blocks. Here we have compared the first number (a) with the second (b) and third (c)
number to check for the greatest. Add print block in do portion. Inside it add a block
and input block. It will print if the condition is true otherwise next condition will be
checked.
Exploring Math with Coding 91

