Hello,
This is the program that I need to do:
Write a program that will sort an array of 20 integer numbers into descending order. The results must be displayed on the screen
in one column.
I tried this, me totally confuse. :| I tried to do this program for one whole day, done flowchart... could not do it. Or it is me or the program.
If someone could help.
Thanks.
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
int main()
{
int a[20];
int i, p, j, sum, lar,sma, an, lar1, lar2; /*i for the number and p for the association of th number*/
i=0;
sum=0;
lar=0;
sma=100000;
do{
printf(" Enter %d:",i);
scanf("%d",&p); /*I use p as my input*/
a[i] = p; /*I use i for my Array*/
i=i+1;
if(p>lar)
lar=p;
if(p<lar && !=lar)
lar1=p;
if (p<lar1 && !=lar1)
lar2=p;
}while(i<20);
j=i;
i=0;
do{
printf("a[%d] = %d\n", i, a[i]);
i=i+1;
}while(i<j); /*I use J as my bonus*/
printf("\n\nThe sum of all this arrays is %d",sum);
printf("\nThe largest number is %d",lar);
printf("\nThe smalest number is %d",sma);
getch();
}