// sorting and swapping a number in Array
#include<stdio.h>
int main ()
{
int a[100], n; // n comes in the end of the Array
printf("Enter a number that you want ");
scanf("%d",&n);
for(int i=0; i<n ; i++) // to pass whole the numbers
scanf("%d",&a[i]);
for(int i=0 ; i<n;i++) // column
{
for (j=0;j<n;j++) // row
{
if(a[i]>a[j]) // if its bigger it will enter and will continue
int temp = a[i];
a[i]=a[j];
a[j]= temp ; // you can say its the Algorathams of changing
}
}
}
I'm not sure, but I think you need to iterate over
i = 0; i < n - 1 and j = i + 1; j < n
then you will iterate only over unique pairs and j will be always bigger than i.
In the current version you can swap things back and forth.
Pavel
Anonymous
\Device\NUL
Eng.Iman
klimi
Ludovic 'Archivist'
ARYA
Sandhit
Amir
Nyasente
.
Cptn
Levi
Matija