Write a C++ program that would input 10
scores and output the Highest and Lowest score
#include <iostream>
using namespace std;
int main()
{
int score=0;
int highestScore=0;
int lowestScore=100000;
for (int i=0;i<10;i++){
cout<<"Enter a score "<<(i+1)<<": ";
cin>>score;
if(score>highestScore){
highestScore=score;
}
if(score<lowestScore){
lowestScore=score;
}
}
cout<<"The lowest score: "<<lowestScore<<"\n";
cout<<"The highest score: "<<highestScore<<"\n";
system("pause");
return 0;
}
Comments
Leave a comment