you can use a goto:
Code:
int Count(int n, int Nbr[MAX])
{
cout << "Number " << n + 1 << ": ";
e:
cin >> Nbr[n];
for (int i=0;i<n;i++)
if (Nbr[i]==Nbr[n]) {
cout << "That number has already been typed in" << endl; goto e;
}
return Nbr[n];
}
if you're finiky about gotos, then do it this way:
Code:
int Count(int n, int Nbr[MAX])
{
int flag_already_typed;
cout << "Number" << n+1 << ": ";
do {
flag_already_typed=0;
cin >> Nbr[n];
for (int i=0;i<n;i++)
if (Nbr[i]==Nbr[n]) {
cout << endl << "that.. blah blah blah .. " << endl; flag_already_typed=1;
}
} while (flag_already_typed);
return Nbr[n];
}
whenever possible, put [ code] and [/code] around your source code