Differences between "iterative" and "repettive" cycle

hi... i'm new in this forum.. i have to ask you a question and i wish you have an answer for this..
what are the differences between "repetitive" and "iterative" cycle?
Can someone give me an example with a for cycle??... thanks a lot!!
closed account (zb0S216C)
Iteration means cycling through memory from 1 point to another. Repetition means doing the same thing again and again until something stops it.

Here's an example of iteration:
1
2
3
4
int Array[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

for(int *Position(Array); Position <= (Array + 9); ++Position)
    // Do something with Position... 

In the above code, Position, a pointer to an int, will iterate through Array until it reaches the end of Array.

Here's an example of repetition:
1
2
3
4
5
6
7
int Input(0);

for(int Attempts(1); Attempts <= 3; ++Attempts)
{
    std::cin >> Input;
    if(Input == 1234) break;
}

In this code, the program requests input from the user. The user has 3 attempts to guess the number, 1234. The loop will repeat itself until either 1234 is entered, or, until 3 attempts have been made.

Wazzak
Last edited on
Topic archived. No new replies allowed.