question about arrays

Hi! I've been dealing with this problem for a couple of hours, maybe you can hel p me:

I have an array of "1" and "0" like this one:

01100111100

And I need to say how many groups of numbers "1" there are, in this case the answer is 2.

I've tried with a while cicle inside a for cicle but it didn't work.

Thank you!
Add a zero to the beginning and loop through them all. Every time you see a 01 pair add one to the total count. Remember to increment by one, not two, and be careful not to go out of bounds (eg start at 1 and check at index and index-1)
Thank you!! that worked perfectly!!
Topic archived. No new replies allowed.