C++ Assignment (Loops)

So I'm pretty new to C++ and I'm not really the best at using loops. Would anyone like to guide me through getting this output?

"Write a program that asks the user how many numbers will be entered and then has the user enter those numbers. When this is done, report to the user the position of the first 7 entered and the last 7 entered. By position we mean, for example, that if the first 7 is the 2nd number entered then its position would be 2. Turn in the following 3 outputs exactly as you see them below to demonstrate that your program works in each case.

Sample screen output 1:

How many numbers will be entered? 8
Enter num: 5
Enter num: 7
Enter num: 6
Enter num: 7
Enter num: 7
Enter num: 3
Enter num: 8
Enter num: 6
The first 7 was in position 2
The last 7 was in position 5
Sample screen output 2:

How many numbers will be entered? 8
Enter num: 5
Enter num: 2
Enter num: 6
Enter num: 7
Enter num: 1
Enter num: 3
Enter num: 8
Enter num: 6
The first 7 was in position 4
The last 7 was in position 4
Sample screen output 3:

How many numbers will be entered? 8
Enter num: 5
Enter num: 1
Enter num: 6
Enter num: 5
Enter num: 9
Enter num: 3
Enter num: 8
Enter num: 6
Sorry, no sevens were entered.
Turn in your source code and by 3 outputs, one exactly like each of the three sample screen outputs given above."


I believe I'm supposed to use a for loop? Not entirely sure, but would anyone care to help me start off? Thank you very much! :]
Last edited on
My favorite
1
2
3
4
for(int x = 0; x < num; x++)
{
    //body
}
Topic archived. No new replies allowed.