Search for question
Question

Exercise 4) (4 pts)

Write a program named "Exercise4.cpp", which reads positive integers until the user types a

negative integer (-1) and displays the total at the end. The following shows two test cases. The

user inputs of the first case are 91, 75, 89, -1, and the second are 78, 89, 95, 81, -1.

(quit).

(quit).

Type one positive integer or -1 (quit).

89

Type one positive integer or -1 (quit).

-1

Type one positive integer or -1

91

Type one positive integer or -1

75

2023 Ⓒ Yoshihiro Kobayashi

Total: 255

Type one positive integer or -1 (quit).

78

Type one positive integer or -1 (quit).

89

(quit).

Type one positive integer or -1 (quit).

81

Type one positive integer or -1

95

Type one positive integer or -1 (quit).

-1

Total: 343

Fig: 1