Hey, i have written a prgram with output as a summary/menu type thing. i need to sort the summary by room numbers. But i dont understand how to.
Heres some of the code:
in the final summary, the for loop prints out all the contents of the arrays as i can understand.what i need to do is e.g. the room numbers entered were 9, 7, 5, 7, 2, 1, 5, 3, i need to sort then in ascending order. Not only that but, i need to be able to get all the other information about that room number to move as well. e.g. name, number of people, destination etc.Code:/* #include <stdio.h> VARIABLES HERE #include <conio.h> #include <stdlib.h> #define SIZE 10 void determine_vehicle_requirements (void); void vehicles (void); //declare function prototypes void summary (void); void calculations (void); void final_summary (void); char name[SIZE][20]; char destination[SIZE]; int room_number[SIZE]; //declare input arrays int num_people[SIZE]; int i=0; int choice; ------------------------------------------------------------------------------------ final summary printf("Room Number\tName\tBookings\tDestination\n"); printf("*********************************************************************\n"); for (i=0;i<=SIZE-1;i++){ printf("%d%17s%7d\t%11c\n", room_number[i], name[i], num_people[i], destination[i]); }*/
Can anyone help?