A few other minor concerns. line 17 'goto start;' is bad form. It'll get the job done in this case, but using goto is archaic and can lead new programmers into trouble. Delete the start: label on line 11, and change line 17 to
continue;
Continue forces execution to go to the top of the current loop, which in this case will accomplish exactly what your goto is diong.
Another minor quibble, line 8 initializes the array with {ssn} which will fill all array elements with the value in ssn. However, ssn has not itself been initialized. Initialize the array with {0} instead. This will allow the isExist() and addSSN() to check for 0 as an unused array element. Some compilers might automatically initialize ints to 0, in which case the code will work as is, but others might not. Whenever there's a possibility of ambiguity, eliminate it.
Now the infinite loop you're getting. The instructions say to have the program quit when the user enters 0, but if they do, the validity check rejects it and asks them to enter a new value. Add a check for 0 before the range check at line 15.
1 2 3
|
if( ssn == 0 ){
break;
}
|
as a counterpart to 'continue', 'break' forces the program to exit the current loop, and will thus effectively terminate the program when 0 is entered. Yes, this makes the while( ssn != 0 ) check redundant, but I'd leave it in as it A) documents for someone reading the code what the loop is for, B) provides a second bailout check if modifications later screw up the new check above.