Question
Program Description Write a C program that would let users to input names in any order. The program then displays the names, sorted in Alphabetical
Program Description
Write a C program that would let users to input names in any order. The program then displays the names, sorted in Alphabetical order.
Your Program should include following key points:
-
- Program must have header comments stating the author of the Program, date, and Program Description.
- Prompt the user to enter the number of names in the list to be sorted, before accepting the names from the user.
- You may use any sorting algorithm (learnt in previous courses, like Bubble Sort, Selection Sort, Insertion Sort, etc.) for sorting the names.
- The program should include 2 Call By Reference Functions:
- One function to sort the names.
Example signature of this function or function declaration:
void sortNames(char **, int*);
- Another function that is called by the sortNames function, for comparing the names (similar to the standard strcmp() function of string.h). DO NOT use the standard strcmp() function of string.h. Simulate the functionality of standard strcmp() function with the help of pointers. (Hint: Similar to what was done in Lab5, but now done with Pointers.)
Example signature of this function or function declaration:
int compareStrings(char*, char*);
- You nay use other standard functions available in string.h (except strcmp()), like strlen(), strcpy(), etc.
- The program should run continuously in a loop till the user wishes to exit.
Sample output / Program run is given here:
How many names in the list?
10
Enter name 1 : Rip Van Winkle
Enter name 2 : Don Quixote
Enter name 3 : Hercule Poirot
Enter name 4 : Agatha Christie
Enter name 5 : Jane Eyre
Enter name 6 : William Wordsworth
Enter name 7 : Charles Dickens
Enter name 8 : Ada Lovelace
Enter name 9 : Charles Darwin
Enter name 10 : Jane Fonda
The sorted names list is:
Ada Lovelace
Agatha Christie
Charles Darwin
Charles Dickens
Don Quixote
Hercule Poirot
Jane Eyre
Jane Fonda
Rip Van Winkle
William Wordsworth
Process returned 0 (0x0) execution time : 254.065 s
Press any key to continue.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started