Question: Write a program that will read a list of numbers of length size, in which each item is either a positive number or -1, indicating

 Write a program that will read a list of numbers of

Write a program that will read a list of numbers of length size, in which each item is either a positive number or -1, indicating the end ofthe list sequence. The program will output the length of longest sequence input before a -7 is input. For example if the input is for 9 values and the list is 4 15 9 1 80 2 1 20 1 then the output would be 3 since the longest sequence has size 3. lfthe input is for 12 values and the list is 14 1 -1 9 -1 8 -1 8 9 5 2 -1 then the output would be 4 since the longest sequence has size 4. Prompt the user for the numbers of elements to be input in the sequence using the input and output format below: Enter the list size: [...] Longest sequence = [...] Notes: (1) The [...] should be replaced with the correct values based on the input entered by the user or respective output. (2) Use two variables, one that keeps track of the current sequence length. and another for the longest sequence length. (3) If you see a 1 set the current length to O. (4) Check if the current sequence length is greater than the longest length, if so update the longest. (5) It is possible forthe list of numbers to have multiple sequences of the same size

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!