Can someone tell me what is the function of "for" in this program? I guess the "for" is just to give to the block the value of "d". The program is the solution of the exercise "while(user==gullible)". I did it knowing that there had to be the "for" i just want to know why.
Please help.
Thanks in advance.(sorry the bad English);
#include <iostream>
usingnamespace std;
int main ()
{
int d, c;
cout << "Please enter any number other than 0: ";
cin >> c;
for (d=1;d<99;d++)
{
getchar();
if (c!=0)
{
cout << "Please enter any number other than " << d << ": ";
cin >> c;
if (c == d )
{
cout << "OTHER THAN " << d << "!!";
getchar ();
goto Exit;
}
}
}
Exit:
getchar ();
return 0;
}
Increasing the value of d is easy. The more interesting question is how to repeat the same block of code more than once without using a while or for loop.