Having trouble understanding this statement!


#1
int end=i+2*(col-1);

what does this tell me when I have a for-loop around it with i being its iterator. And “col” is an integer value;


#2

Says that whatever is declared next defines the conclusion.

i + 2 * (col - 1)

but end itself must be tested.


Aside:

Don’t be scared to use a little whitespace. It goes to readability.


#3

Just took a second look at it and it blew my mind. Its used for creating a matrix of a certain squared number. I was typing it in as

int end = i*2+(col-1);

instead of typing it correctly as:

int end = i*row+(col-1); //when inserted inside the first for-loop;

Yes, int end, row, and col are integer values.
Thanks! :slight_smile:


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.