# Thread: Need help fast with counting consecutive occurances

1. ## Need help fast with counting consecutive occurances

Hi, I am new to prgramming and am having a little trouble. I need help with I am working on this program...a user inputs an integer between 1 and 100 (for example, 50). I have a for loop that generates random numbers between 1 and 100 and iterates according to another user input. Now i need to figure out the number of consecutive times that a random numbers occurs below or above the user input.
For example...
cin>>50
cout<<"How many random numbers would you like?";
cin>>10

Output: 24 34 54 67 98 12 34 44 99 10 (random numbers)

This is what I need to figure out...how many times the random numbers occurs consecutively...
24 and 34 are 2 consecutives below 50
54, 67, and 98 a 3 consecutives above 50
12, 34, 44 are 3 consecutives below 50

Thank you!

2. Well you pretty much wrote the logic of what you want to achieve.

if this > previous && this <= 50 then increment count, else reset count