I have to do the following exercise:
Read 3 integer values and sort them in ascending order. At the end, show the values in ascending order, a blank line and then the values in the sequence as read.
The part of sorting the numbers I got. I now need to display the index (counter) outside the for.
#include<stdio.h>
int main() {
int n, i, maior, menor, meio;
scanf("%d", &n);
maior = n; menor = n; meio = n;
for(i = 1; i <= 2; i++) {
scanf("%d", &n);
if (n > maior) {
maior = n;
} else if (n < menor) {
menor = n;
} else {
meio = n;
}
}
printf("%d\n", menor);
printf("%d\n", meio);
printf("%d\n", maior);
printf("\n");
return 0;
}