Question: Write a program in c++ to accomplish each of the following. Assume that allthe manipulations occur in main (therefore, no addresses of pointer variables are
Write a program in c++ to accomplish each of the following. Assume that allthe manipulations occur in main (therefore, no addresses of pointer variables are needed), and assumethe following definitions:struct gradeNode {char lastName[ 20 ];double grade;struct gradeNode *nextPtr;};typedef struct gradeNode GradeNode;typedef GradeNode *GradeNodePtr; a) Create a pointer to the start of the list called startPtr. The list is empty.b) Create a new node of type GradeNode that is pointed to by pointer newPtr of type Grade-NodePtr. Assign the string "Jones" to member lastName and the value 91.5 to membergrade (use strcpy). Provide any necessary declarations and statements.c) Assume that the list pointed to by startPtr currently consists of 2 nodesone containing"Jones"and one containing "Smith". The nodes are in alphabetical order. Providethe statements necessary to insert in order nodes containing the following data forlastName and grade:"Adams" 85.0"Thompson" 73.5"Pritchard" 66.5Use pointers previousPtr, currentPtr and newPtr to perform the insertions. Write a comment statingwhatpreviousPtr and currentPtr point to before each insertion. Assume that newPtr alwayspoints to the new node, and that the new node has already been assigned the data.d) Write a while loop that prints the data in each node of the list. Use pointer currentPtrto move along the list
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
