I am writing a program that will ask the user for integers and then put them into descending order. I a close, but i don't know which numbers to put into my nested for loops. Right now it cuts off the highest number and im not sure why?
#include<iostream>
#include<iomanip>
#include<string>
#include<cmath>
usingnamespace std;
int i;
int j;
constint max = 10;
void hi_2_lo (int num[]);
int main()
{
constint max = 10;
int Jethro[max];
string ans = "yes";
while (ans == "yes")
{
cout<<"Please input ten integers to be put into descending order: "<<endl<<endl;
for(i = 0; i < max; i++)
{
while(!(cin>>Jethro[i]))
{ cin.clear();
cin.ignore(10000,'\n');
cout<<"Please input only integers"<<endl;
}
}
cout<<endl<<endl;
hi_2_lo(Jethro);
for(i = 0; i<max; i++)
{
cout<<Jethro[i]<<endl;
}
cout<<"Thank you for using my program"<<endl;
cout<<"Would you like to run this again? yes to proceed"<<endl;
cout<<"anything else to end the program"<<endl;
cin>>ans;
}
system("pause");
return 0;
}
void hi_2_lo(int num[])
{
int y = num[0];
int low;
for (i=0; i<10; i++)
for (j=9; j>-1; j--) {
if(num[j-1] < num[j]) {
low=num[j-1];
num[j-1] = num[j];
num[j] = low;
}
}
return ;
}