Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program in c++ to accomplish each of the following. Assume that allthe m

ID: 3674780 • Letter: W

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 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 nodes—one 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

Explanation / Answer

a)
GRADENODEPTR startPtr = NULL;

b)

GRADENODEPTR newPtr;
if (newPtr != NULL)
{
newPtr = malloc (sizeof(GRADENODE));
strcpy(newPtr->lastName, "Jones");
newPtr->grade = 91.5;
newPtr->nextPtr = NULL;
}

d)

currentPtr = startPtr;
while(currentPtr !=NuLL)
{
printf("last name = %s Grade = %6.2f ",currentPtr ->lastname,
cuurentPtr->grade);
currentPtr = currentPtr ->nextPtr
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote