0

Line Robot - Basic lessons - Comments

Comments are parts of Your code which compiler ignore. Compiler is a program that translates Your C++ code into a code microcontroller understands. Not being for hardware, comments are just for us, humans. These are notes we leave in the code so that we, and anybody else, can understand better what the code does. For example, if we feel that a name of the variable is not meaningful enough we will be able to reveal its purpose it with a comment:
void RobotLine::loop() {
	int i; // This variable will be a counter
}
Any text behind "//" in the line is a comment. Note that this is a poor example as it is much better to give the variable better name, like:
void RobotLine::loop() {
	int counter;
}
To comment more than one line, use "/*...*/", like here:
void RobotLine::loop() {
	/* This is a part of the
	program that will do something useful*/
	int counter;
	...
}

Task: correct the program.

This program will not compile. Add 2 characters to correct the error and enable the compiler to finish the job. It is not important what the result of the program will be.

void RobotLine::loop() {
	if (2 = 1) 2 cannot be 1
		print("Done");
}