Please repair my coding for descending...

The process is wrong, help me ...
there are the code :

#include <stdio.h>
#include <conio.h>

void sorting (int input[],int data); //deklarasi fungsi sorting
void main()

{
int input[100],data;
printf("Masukkan banyak data (Maksimum 100) : "); //instruksi memasukkan input
scanf("%d",&data);

if(data>100) //jika input > 100
printf("Maaf, banyak data harus antara 1 s/d 100 !");
else //jika input <= 100
{
for(int i=0;i<data;i++)
{
printf("\nMasukkan data ke %d : ",i+1);
scanf("%d",&input[i]);
}
sorting(input,data); //panggil fungsi sorting
}
getch();
}

/*================fungsi sorting==========================*/

void sorting(int input[], int data)

{
int i, j, temp, k;
for(i=0;i<data;i++) //operasi sorting
{
for(j=0;j<data;j++)
{
if(input[j]>input[i])
{
temp=input[i]; //operasi swapping
input[i]=input[j];
input[j]=temp;
}
}
printf("proses pengurutan ke-%d ",i+1);
for (k=0;k<data;k++){
printf (" %d",input[k]);
}
printf(" \n");
}
printf("\n\nDescending : "); //menampilkan sorting descending
for(i=0;i<data;i++)
{
if(i==data)
printf("%d",input[data-i-1]);
else if(i<data)
printf("%d ",input[data-i-1]);
}
getch();
}
Last edited on
What exactly is that code doing right now?
Also, the tags are [code].
Topic archived. No new replies allowed.