Heyy i'm new to this language & i'm luving it. I need some help here guys. I was given this question by my lecturer and i'm not sure what the question wants

The array below contains the maximum speed per day attained by mr Speedo on his daily travels to Harare by car.
Write a program to arrange the array in ascending order
200, 190, 96, 102, 82, 122

Try out the following code:

#include<iostream.h>
#include<conio.h>
void main()
{
//clear the screen.
clrscr();
//declare variable type int
int a[10],i,j,temp;
//Input the two numbers save them in arrays.
for(i=0;i<5;i++)
{
cout<<"Enter the no :";
cin>>a[i];
}
//sort the array
for(i=0;i<5;i++)
{
  for(j=0;j<5;j++)
  {
    if(a[i]<a[j])
    {
     temp = a[i];
     a[i] = a[j];
     a[j] = temp;
    }
  }
}
//Print the array.
for(i=0;i<5;i++)
cout<<a[i]<<endl;
//get character
getch();
}

So many bad things in that code. #include<iostream.h> and #include<conio.h> are not standard. void main() is not standard as well. main() should only ever return an int. clrscr() is not portable. Why do you have an array of 10 for 5 values?

I am just a beginer, sorry for the mistake. But I am very eager to learn the language. If you don't mind, could you please rewrite the code in the standard manner?

No because that would be giving the OP correct code and I am not going to help he OP with there homework since the OP provided nothing but the problem statement. I am pretty sure you could do a google search and see what a correct piece of code looks like.

Okay. Sure.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.