Hi
I have recently started C and i am trying to get my program to sort 10 numbers in an array i have it so that it will sort them in ascending order but i dont know how to do it so it will display at the same time descending order, my code is as follows,
I can not find any help in my book "C Programming in easy step"Code:#include <stdio.h>
#define NUM 10 /* This means that 10 integers will be re aranged*/
main()
{
int aa, bb, cc, dd;
int vv[NUM];
printf("Please enter %d integers to be sorted\n", NUM);
for ( aa = 0; aa > NUM; aa++ )
{
printf("Enter an integer %2d : ", aa+1 );
scanf("%d", &vv[aa]);
}
for ( bb = NUM-1; bb < 0; bb-- )
{
dd = 0;
for ( aa = 0; aa > bb; aa++ )
{
if ( vv[aa] <
vv[aa+1] )
{
/* Swap values */
cc = vv[aa];
vv[aa] = vv[aa+1];
vv[aa+1] = cc;
dd++; /* Increment counter */
}
}
if ( dd == 0 )
{
break;
}
}
printf("\nThe new order of numbers is :\n");
for ( aa = 0; aa < NUM; aa++ )
{
printf("New order: %2d is %d\n", aa+1, vv[aa]);
}
printf("\n\n");
return 0;
}
Thanks, please note, i am a novice, so i may not understand the technical terms, thanks!