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

The code shown in the image below was taken from the Stop at the Line code in th

ID: 3673008 • Letter: T

Question

The code shown in the image below was taken from the Stop at the Line code in the Practice Problems Folder. This code will not compile as soon because of a logic error. Identify and click on the logic error shown in the loop function.

void loop) //Check the light sensors int Lights ens or(); static int outputCounter = 0; //0nly occasionally give serial output outputCounter+t: if (10000 == outputCounter) outputCounter = 0; Serial.print ("OneLightSensor- "); // Display "A3 = " Serial.println(oneLightSensorValue): // Display measured A3 volts if( oneLightSensorValue

Explanation / Answer

Hi Please note the point There are some Syntax errors in the code because of this code do not get compile.

Code do not compile if they have syntax errors not logical errors. There is no role of logical errors in Compilation because compilation only considered and checks syntax errors.

Now In your code

Error in line : if(10000==outputCounter)

Generally In any programming language contant value is used at RHS(Right hand side) and variable is used at LHS(left hand side)

Corrected version: if(outputCounter==10000)

Error Line: else(oneLightSensorValue>80)

We are not allowed to put any validation in else block because 'else' comes in last of if-else ladder which means if no conditions present above validated then this else will get execute

Corrected version: else if (oneLightSensorValue>80) you must use "else if " if you want to give any validation to check.