Help me understand this please.


I'm doing some beginners c++ and i have trouble understanding this particular part of a code.

I wonder what the V[i-1] has to say in this code? Why is it minus one? does it mean that the number in i ex. 11 - 1 = 10? or does it mean that -1 is something in the array?

if(V[i-1] > 25) {
cout << "Wrong input";
cout << endl << endl;
return (0);

sorry for the bad posting, first time poster.
Yeah, it's just a normal expression, i.e. i minus one.
It is just the effect or reminescing a release of effect.

This is normal when reducing numbers

- Elmo
closed account (S6k9GNh0)
i is probably an integer, 1 is a constant, V[i-1] says, "Fetch type of V array at the location V with offset i - 1". Example:

Let i equal 4.

This says V[4-1] which is the same as saying V[3]. The number in the brackets indicates the element to fetch in the array. I can't tell you why they subtracted 1 and/or compared it to 25 without looking at more code (if the code has any use at all).
Say V[1] = 45 and V[2] = 15. If you're running through a loop and i is currently at the value of 2, then i - 1 is, well, 1. So V[i] is the same thing as V[2] and V[i-1] is the same as V[1].
Topic archived. No new replies allowed.