Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

int a=2, b=0, result1=0,result2=0; int count =0; void setup() { Serial.begin(960

ID: 2080235 • Letter: I

Question

int a=2, b=0, result1=0,result2=0;
int count =0;
void setup()
{
Serial.begin(9600);
}
void displayTerminal (int result)
{
Serial.print(result);
}
void loop()
{
while(1)
{
count ++;
result1=a++;
result2=b++;
  
Serial.print In();
Serial.print("COUNT=");
displayTerminal(count);
Serial.print In();
displayTerminal(result1);
displayTerminal(result2);
delay(5000);
}
}

Assume that you are observing the output of this program on the serial monitor window supplied with Arduino IDE.Afer the first two literations of the while loop, the output on the serial monitor window will be which one of the following?

a) COUNT=1

20

COUNT =2

31

b)

COUNT=1

21

COUNT =2

32

c)

COUNT=1

42

COUNT =2

53

Explanation / Answer

Ans- a) count =1

20

Count =2

31

Explanation

As given a++, b++ are postfix addition thus when line executes the value does not change, the initialized values of a and b I.e 20 is given

In the second case result1 is 3 and result 2 is 1

And it is displayed.