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

Recommended Answers

All 6 Replies

Try out the following code:

void main()
//clear the screen.
//declare variable type int
int a[10],i,j,temp;
//Input the two numbers save them in arrays.
cout<<"Enter the no :";
//sort the array
     temp = a[i];
     a[i] = a[j];
     a[j] = temp;
//Print the array.
//get character

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, learning, and sharing knowledge.