Hi,
I want to know how i can print out the 3 numbers i asked from the user in the ascending numerical order. e.g.
user inputs: 5 1 9
ascending numerical order: 1 5 9
Hi,
I want to know how i can print out the 3 numbers i asked from the user in the ascending numerical order. e.g.
user inputs: 5 1 9
ascending numerical order: 1 5 9
Do a search on qsort
I remember my lecturer doing it in a very easy way with just the stdio.h
If you only have three number to sort, what about using a simpler sort?
Code:#define SIZE 3 int i, j, temp; int a[SIZE] = { 5, 9, 1 }; for(i = 0; i < SIZE - 1; i++) { for(j = i + 1; j < SIZE; j++) { if(a[i] > a[j] { temp = a[i]; a[i] = a[j]; a[j] = temp; } } } for(i = 0; i < SIZE; i++) printf("\n %d ", a[i]);
The problem is the user enters the number so i use scanf to ask for the value.
So put the values into the array
You need to get busy, get out your notes, your book, look over the posts here, and get some work of your own done on this, Yizi.
Programming requires practice, not just asking for help on a forum, and waiting for the code to be done for you.