The objective of this Programming Project is for students to write a C Program and to apply their knowledge of working with Pointers with two-dimensional arrays and passing the same through Pass by Reference Functions in C programming language.

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:

1. Program must have header comments stating the author of the Program, date, and Program Description.

2. Prompt the user to enter the number of names in the list to be sorted, before accepting the names from the user.

3. You may use any sorting algorithm (learnt in previous courses, like Bubble Sort, Selection Sort, Insertion Sort, etc.) for sorting the names.

4. The program should include 2 Pass By Reference (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 Lab6, but now done with Pointers.) Example signature of this function or function declaration:
int compareStrings(char*, char*);

5. You nay use other standard functions available in string.h (except strcmp()), like strlen(), strcpy(), etc.

6. 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
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.