### Finding positions of specific numbers in an input stream

The goal of the program is to ask the user for a number. This number determines the amount of input values that follow. The program then allows the specific count of inputs to be entered and then searches that input stream for a specific value, and in this case the first and last time this number is found in the stream.
For example, the program wants to search the input stream for the number 5. The program asks "how many numbers will be entered?". If you were to enter 3, the program should ask for 3 numbers. The program then searches that stream for the first and last time a 5 shows up. If the numbers entered are 5,3,5--the first time 5 shows up is position 1, and the last, position 3. Also, if no fives are found, then a message stating that should appear.
In our class we have just began learning while loops. The code i have so far allows me to enter the desired number of numbers and enter the first number. However, after that the program just ends. I am honestly not sure if i am even close to something resembling legit structure. I am looking for hints or suggestions. thank you for your time.

This is what i have so far:

#include <iostream>
using namespace std;

int main()
{
int number;
int values;
int loopcount;
int position;
int count;

cout << "How many numbers will be entered: ";
cin >> number;

cout << "Enter number: ";
cin >> values;
while (count <=number)

{
cout << "Enter number: ";
cin >> values;

while (values==8)
{
position = values;
position++;

cout << "The first 8 was in position " << position << endl;
cout << "The last 8 was in position " << position << endl;

cout << "Enter number: ";
cin >> values;
count++;
}
if (values!=8)
{cout << "Sorry. No eights were entered." << endl;
}

}
return 0;
}

Topic archived. No new replies allowed.