Explanation of the program
[Explain (where applicable)
l how the loop executes
l · how the written function works
l · and anything that you think is necessary
1) for ( init; condition; increment ) {
statement(s);
}
After the body of the 'for' loop executes, the flow of control jumps back up to the increment statement.
f it is true, the loop executes and the process repeats itself (body of loop, then increment step, and then again condition). After the condition becomes false, the 'for' loop terminates.
2) void myFunction() {
// code to be executed
}
A function is a block of code which only runs when it is called.
You can pass data, known as parameters, into a function.
Functions are used to perform certain actions, and they are important for reusing code: Define the code once, and use it many times.
Comments
Leave a comment