Is indentation in an if else statement important for code execution, or is it just something to do for cleaner code?
while(c != cols) {
if(r == pad + 1 && c == pad + 1) {
cout << greet;
c += greet.size();
} else {
if(r == 0 || r == rows - 1 || c == 0 || c == cols - 1)
cout << "*";
else
cout << " ";
++c;
}
}
I'm not sure why the prefix increment of c gets done regardless of whether r=0 or not.
An asterisk is written if the if statement is true.
Otherwise, a blank space is written and c is increased.
That's how I see it, however c is increased regardless of the values of r or c.
This is what it says in the book, however I couldn't locate an explanation:
Notice how the distinct indentation of ++c; emphasises the fact that it gets performed regardless of whether we are on the border or not.