for loops have the syntax:
Code:
for(initialization; loop condition; counter control)
{
// your code here
}
for example, to print out the first 5 positive integers, one may do:
Code:
int i;
for (i = 0; i < 5; i++)
{
cout << i << endl;
}
here the initialization part of the for loop declaration is 'i = 0', the loop condition is 'i < 5' and the counter control is 'i++'.
the first part, initialization, is usually used to set the variable ('counter') to some initial ('starting') value. the loop condition (middle part) means that the loop will only execute if the statement there is true (ie loop while i < 5, here). the counter control simply increments the counter ('i') by one, after each run through the loop, or 'iteration'. note that we left out 'i++', the loop would never end, as i is always zero.
for your situation, i would declare an int starting at 0, before the for loop. this will be used to count the number of negative numbers. that is, each time you read in a negative number, increment this negative number counter, and if you read in a non-negative number set the counter back to 0. it will be used to control your for loop. ie, you want to loop 'while the last 3 numbers entered are negative.'
this isnt all of the solution, but i hope it helps.