In the following code. I declared a variable named number and initialized it with 100 (the limit to print the even number). I used a for loop that executes up to 100 times and for each iteration of the if statement checks the number is even or not. After printing each even number, the value of i is increased by 1.
To check the number, I divided the number by 2 if it does not leave any remainder, the number is even and the print statement prints that number.
In the following code. I declared a variable named number and initialized it with 100 (the limit to print the even number). I used a for loop that executes up to 100 times and for each iteration of the if statement checks the number is even or not. After printing each even number, the value of i is increased by 1.
To check the number, I divided the number by 2 if it does not leave any remainder, the number is even and the print statement prints that number.