WAP to Print even number in range of 100 to 200 on serial monitor.
Last Updated : 15 Jul 2025
New Question
Solution:
void setup(){
Serial.begin(9600);
for(int i=100;i<=200;i++){
if (i%2==0){
Serial.print(i);
Serial.print(" ");
}
}
}
void loop(){
}
Outpt Description:
The Serial Monitor will display:
100 102 104 106 108 110 112 114 116 118 120 122 124 126 128
130 132 134 136 138 140 142 144 146 148 150 152 154 156 158
160 162 164 166 168 170 172 174 176 178 180 182 184 186 188
190 192 194 196 198 200
Code Explanation:
-
Initialization (
setup
function):Serial.begin(9600);
: Initializes serial communication at a baud rate of 9600.
-
Number Printing:
for (int i = 100; i <= 200; i++)
: Iterates through numbers from 100 to 200.if (i % 2 == 0)
: Checks if the number is even.Serial.print(i);
: Prints the even number to the Serial Monitor.Serial.print(" ");
: Adds a space after each number to separate them visually.
-
Empty Loop (
loop
function):- The
loop
function is empty because the task is completed in thesetup
function, and there is no need for continuous execution.
- The
Meanwhile you can watch this video
Watch Video