Created
October 4, 2022 10:09
-
-
Save azeezco/9c681c29e57cae48a82247b46a994cb3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
var num = 0; //Declaring and initializing variable 'num' | |
while (num <=29) { // while num is less or equal to 29. | |
num = num + 1; // increment num by 1 and set it it to num. | |
if (num == 30) { // check if num is equal to 30. | |
print("The number is at $num"); | |
break; // break the while loop. | |
} | |
print(num); //print num for every value it increments | |
} | |
print(""); | |
var i; // Declaring variable 'i' | |
for (i=0; i<=30; i++){ //loop through 0-30, increment each time | |
if (i%2 != 0){ //check that the remainder of i/2 is not equal to 0 | |
print(i); //print i for every time the condition is met | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment