Write a C++ program to solve the following problems. Through out this program as
ID: 3643409 • Letter: W
Question
Write a C++ program to solve the following problems. Through out this program assignment you need to use pointer notation.You cannot use array notation. -5 points if you use array notation anywhere in your program except for declaration of your array or reading names form the keyboard.
Example of array notation: A[0], A[3][10], A[0][3], etc
Example of pointer notation: *A, *(*(A+2)+3), *(*A+2), etc
Write a program to prompt the user to enter number of names to be sorted. This number of name has a range from 1 to 20 people. Once you have this number then you need to prompt the user to input names as many number of items as he has specified. These names could be in any order. Your program has to sort them (by first name) in ASCENDING order. Once you are done, you need to clear screen and print the result. Your first output should be the original set of names (unsorted), then followed by second set of your output (sorted names). At the end of the list, your program has to check whether or not the user wants to quit. If he selects "Q" or "q", then your program should clear the screen and terminate your program.
Note: You need to pass your data by using pointer to a function called:
sort_name(char *name [], int *item)
You can clear screen by printing new line character or endl about 20 times.
Example:
Please enter number of names you want to sort: 4
Please enter 5 items:
John Doe
Joe More
Steven Smith
Marry Ann
UNSORTED
John Doe
Joe More
Steven Smith
Marry Ann
SORTED
Steven Smith
Marry Ann
John Doe
Joe More
Do you want to quit? Q
Explanation / Answer
#include #include #include using namespace std; char* data[20]; char getChar(char* text,int index){ return *(text+index); } char* getString(char* arr[],int index){ return *(arr+index); } int compare(char* s1,char* s2) { int i=0; for(;getChar(s1,i)!=0 && getChar(s2,i)!=0;++i) { if(getChar(s1,i)>getChar(s2,i))return 1; else if(getChar(s1,i)Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.