Q:

How do I make my code sort input in ascending order?

i want input randomly 3 number and then Ascending order output.
big one->small one
you know what i mean?
#include <stdio.h>
int main(void) {

    int a, b, c;
    int min, mid, max;

    scanf("%d %d %d", &a, &b, &c);

    if (a > b) {
        max = a;
        min = b;
    }

    else {
        max = b;
        min = a;
    }

    mid = c;

    if (c > max) {
        max = c;
        mid = a > b ? a : b;
        min = a < b ? a : b;
    }

    else if (c < min) {

        min = c;
        mid = a < b ? : a : b;
            max = a > b ? : a : b;

    }

    printf("1:%d 2:%d 3:%d", max, mid, min);

    return 0;

}

A:

The code is illogical and tangled up. The simplest way of sorting 3 numbers is to use swap three times:
if (a > c) swap(&a, &c);
if (a > b) swap(&a, &b);
if (b > c) swap(&b, &c);

Introducing new variables is not necessary, and I'm not convinced they are all set on every control path so that could produce undefined results. To build swap, see Is there a built-in way to swap two variables in C, or use this one:
void swap(int* a, int* b)
{
   int t = *b;
   *b = *a;
   *a = t;
}

Finally, don't forget to check the return value of scanf; it should be 3 in your case.

