[Solved] C++: Using for loop I need to take infinite values of a point using arrays. How can I take values of point [ ] until 2 points of are equal


To test if two consecutive numbers are equal, you dont need 100 elements, you need 2:

int points[2], counter = 1;

// Read in first point:
cin >> points[0];

// Read until we meet our condition:
do {
    // Read a point into the next part of the array.
    cin >> points[counter];
    // toggle counter between 0 and 1
    counter = (counter + 1) % 2;
// Check if we are done:
} while (points[0] != points[1]);

Here is a live example.

2

solved C++: Using for loop I need to take infinite values of a point using arrays. How can I take values of point [ ] until 2 points of are equal