What will the following 2 Arduino code print on the serial
monitor?
int x =1 ;
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println(x);
x = x+1;
}
And
int x =1 ;
void setup() {
Serial.begin(9600);
}
void loop() {
if (x < 10) {
Serial.println(x);
x = x+1;
}
else {
Serial.println(x);
}
}
the first program will print
number from 1 than add 1 to it and than print 2
and keep on adding 1 to prevoius number and printing .
i have taken two snapshots of serial monitor.
actually its a infinte loop.
your second program will keep on printing 10 on serial monitor again and again
Get Answers For Free
Most questions answered within 1 hours.