#include<iostream.h>
#include<conio.h>
void sel_sort (int array[20],int x)
{
int i, j, first, temp;
for (i= x - 1; i > 0; i--)
{
first = 0;
for (j=1; j<=i; j++)
{
if (array[j] < array[first])
first = j;
}
temp = array[first];
array[first] = array[i];
array[i] = temp;
}
return;
}
#include<iostream.h>
#include<iostream.h>
void main ()
{
clrscr();
int ch,x=0,r,i,arr[50];
cout<<"1) Sort and array\n";
cout<<"2) Sort an array and insert a integeraccordingly\n";
cin>>ch;
switch(ch)
{
case 1 : cout<<"How many terms will be there in the array ?\n";
cin>>x;
for(i=0;i<x;i++)
{
cin>>arr[i];
}
sel_sort(arr,x);
break;
case 2 : cout<<"How many terms will be there in the array ?\n";
cin>>x;
for(i=0;i<x;i++)
{
cin>>arr[i];
}
sel_sort(arr,x);
cout<<"Input the integer\n";
cin>>y;
clrscr();
for(r=0;r<x;r++)
{
if(y<arr[r])
{
y=arr[r+1];
r++;
}
getch();
}

I prefered sel-sort because I have already got the function in my HDD so Instead of writing a whole new prog. I will just access the first and last term of the resultant array.

>I prefered sel-sort because I have already got the
>function in my HDD so Instead of writing a whole new prog.
That's not the point. Your solution is painfully wasteful compared to the obvious solution, even if you generalize the obvious solution to take any amount of numbers.

Um, yeah that one was over my head...lol. I'm a newbie as well and I was thinking just a simple cout and cin to read in 5 numbers, then some nested if else statements or lazy person's if else line.

You don't need to sort. Just declare an array of 5 integers and declare an integer called "largest" and an integer called "smallest". Start with element 0. Assign "largest" "and smallest" to that value. Then go through the other 4 integers one at a time. Compare each integer in the array to the current "largest"and the "smallest". If the integer is smaller or larger than the current "smallest" or "largest", assign "smallest" or "largest", whichever the case may be, to the value of the integer.

You actually don't even need the array if you don't care about storing the 5 integers for later use and only care about the largest and smallest. Just compare as you read in the numbers.

the selection sort atish00 suggested actually works by going through your list of numbers and finding the smallest number this could easily be modified to find the greatest also.
But still, it is overkill. The best way is to just compare the numbers to the current highest and lowest as they are inputted. That way you don't even need to store the inputs.

>sorry even I am a new programmer and started c++ just 10 months ago.
10 months, eh? Is that on and off? Or with regular practice and reading? I can forgive the bad habits caused by your choice of compiler, but if that program is indicative of your programming ability, I think hanging around on Daniweb can help you jump to the next level.

>How many months does it takes to get into Beautiful code club
The Beautiful Code club isn't about how long you've been programming, it's about how seriously you work toward elegance. ;) It could be as little as a few months to get situated with programming, or it could never happen. It all depends on your attitude.

I'm going to develop new pos system. So I need to choice right database for that. My software work in network.
System going to be handle one thousand transactions per ...