Let's see what happens. User enters '1' to enter SIN.
1 2 3 4 5 6 7 8 9
|
for (i = 0; i < SIZE; i++){
cout << "Enter SIN number. Press 0 to stop entering numbers." << endl;
cin >> myArray[i];
//cout << "i = " << myArray[i] << ", " << endl;
if (myArray[i] == 0){
break;
}
}
break;
|
Each time the user enters a SIN, value of "i" increases by one. If the user enters 3 SIN, by the time you exit this part "i" should be 3 (including entering of "0" to exit). Say the 3 SIN are 3, 5 and 10;
myArray[0] = 3;
myArray[1] = 5;
myArray[2] = 10;
myArray[3] = 0;
Now the user prints it yada yada and wants to enter more SIN.
User enters "1" again to go to
case 1.
for (i = 0; i < SIZE; i++)
"i" is assigned back to 0. Let's say the user wants to input one new SIN and it is 1000. Your array looks like this now.
myArray[0] = 1000;
myArray[1] = 0; <----- To exit.
myArray[2] = 10;
myArray[3] = 0;
Listen to mutexe's suggestion.
Edit: Additionally, knowing exactly how big your array is will prevent you from printing garbage values (or 0 values if your initialized your array) by having a proper limit set for your for loop conditions (instead of just using 100).
If there's only 3 elements entered in your array, your array size isn't 100 right? What happens when you try to print myArray[4] and more?