Answer:
- #include <iostream>
- using namespace std;
- int main()
- {
- int highest = 0;
- int score;
- do{
- cout<<"Input a score: ";
- cin>>score;
-
- if(score > highest){
- highest = score;
- }
- }while(score >= 0);
-
- cout<<highest;
- return 0;
- }
Step-by-step explanation:
Firstly, create a variable highest and initialize it with zero (Line 5). Next, create a do while loop (Line 7 - 14). Within the loop prompt user to input a score (Line 8-9) and if the current score is higher than the highest variable, assign the score to highest variable (Line 11 - 13).
After finishing the loop when user put in any negative value, the program shall be able to print out the highest input score (Line 16).