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

PLEASE DONOT USE STRUCT AND NODE(->). Instruction: You must use pointers in C-pr

ID: 652807 • Letter: P

Question

PLEASE DONOT USE STRUCT AND NODE(->).

Instruction: You must use pointers in C-program. No arrays, no structures. For example, if you need an array of floats to hold the scores, do not use float score[15]. Rather use float *score, then use dynamic memory allocation to hold required memory. You must use memory optimally, that is if you have only 6 scores, you must point to a memory chunk of sizeof(float)*6 bytes. Similarly, to hold a name, instead of doing it with 2D char arrays, use 2D pointers (char firstName[15][20] char **firstName). Problem: Write a menu based C program to maintain student records. Your program should take the following inputs: 1. Student first name (max. 20 characters) 2. Student last name, (max. 20 characters) 3. Student scores (float/double), eg. 85.4 Your program should be able to take records of a minimum of 5 students. After taking the records, you should provide 8 functionalities to the user. 1. Print records

Explanation / Answer

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//Create a structure node
struct node
{
char firstName[15];
char lastName[15];
double score;
struct node *next;
};
//Method definition of insertData
void insertData(struct node** head_ref, char firstName[],char lastName[],double score)
{
struct node* new_node = (struct node*) malloc(sizeof(struct node));
strcpy(new_node->firstName,firstName);
strcpy(new_node->lastName,lastName);
new_node->score = score;
new_node->next = (*head_ref);
(*head_ref) = new_node;
}

void printRecords(struct node *node)
{
printf("First Name Last Name Score ");
printf("---------------------------------------------------- ");
while (node != NULL)
{

printf(" %10s %10s %0.2lf ", node->firstName,node->lastName,node->score);
node = node->next;
}
}
/*Add a new record

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