Write a program that asks the user to type a positive integer. When the user types a negative value the program writes ERROR and asks for another value. When the user types 0, that means that the last value has been typed and the program must write the average of the positive integers. If the number of typed values is zero the program writes 'NO AVERAGE'.
In this program, max is used to count the number of positive inputs. In the working program, max is incremented only when a positive number is inputted, as it should. However, in the non-working program, max is incremented for each input, including negatives and the zero.
when doing else you need {} around that else statement
The brackets are only necessary when there's multiple statements in the else clause. In this case, there's only the one output statement.