Thursday, September 18, 2008

Highest, Lowest Code in Programing C++

sample output:

enter 5 scores:
5 9 2 10 6
The numbers are 6 10 2 9 5
The highest score is 10
The lowest score is 2
The score and their difference from the highest are
5 off by 5
9 off by 1
2 off by 8
10 off by 0
6 off by 4

Please repeat the process? [ y for yes, n for no]:
--------------------------------------------------------------

#include
#include
#include
#include

using namespace std;

main()
{
float a[5];
float highest=0, lowest=999999999;
int i;
char cont='Y';
do{
if(cont=='y' || cont=='Y')
{
system("cls");
cout<<"Enter 5 scores: ";
for(i=0;i<5;i++)
{
cin>>a[i];
}
cout<<"The numbers are ";
for(i=4;i>=0;i--)
{
cout< }
cout<<"\n";
for(i=0;i<5;i++)
{
if(lowest>a[i])
{
lowest=a[i];
}
if(highest {
highest=a[i];
}
}
cout<<"The highest score is "< cout<<"The lowest score is "< cout<<"The score and their difference from the highest are \n";
for(i=0;i<5;i++)
{
cout< }
cout<<"Please repeat the process? [ y for yes, n for no]:";
cin>>cont;
getch();
}
else{ exit(0);}
}while(cont!='y' || cont!='Y');
}

If you like this post will you buy me a beer?

No comments: