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

You must use pointers for this lab. No arrays, no structures. For example, if yo

ID: 654145 • Letter: Y

Question

You must use pointers for this lab. 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.

Write a menu based 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<conio.h>

int main()

{

       char **fname;

       char **lname;

       char *name;

       float *score;

       printf("wlecom to Student Records Maintance System ");

       printf("Number of records you want to enter(min-3):");

                     scanf("%d", &noRecords);

                     fname=(char**)malloc(10*sizeof(*fname));

                     lname=(char**)malloc(10*sizeof(*lname));

                     score = (float*)malloc(10*sizeof(float));

                     for(int i=0;i<noRecords;i++)

                     {

                     printf("Enter score of %d student:",i+1);

                     scanf("%f",&score[i]);

                     fname[i]=(char*)malloc(20+1);

                     printf("Enter fname of %d student:",i+1);

                     scanf("%s",fname[i]);

                     lname[i]=(char*)malloc(20+1);

                     printf("Enter lname of %d student:",i+1);

                     scanf("%s",lname[i]);

                     }

       do

       {

       printf(" *Print records(Press 1) ");

       printf("*Add new records(Press 2) ");

       printf("*Delete record(s)(Press 3) ");

       printf("*Search by last name(Press 4) ");

       printf("*Search by score(Press 5) ");

       printf("*Sort by last name(Press 6) ");

       printf("*Find median score(Press 7) ");

       printf("*Exit the program Print(Press 0) ");

       printf("*Enter Your choice:");

       scanf("%d",&choice);

       switch(choice)

       {

       case 1:for(int i=0;i<noRecords;i++)

                     {

                           printf(" First name: %s Last name: %s Score: %f ",*(fname+i),*(lname+i),*(score+i));

                     }

                 break;

       case 2:

                     printf("Enter score of the student %d:",noRecords);

                     scanf("%f",&score[noRecords]);

                     fname[noRecords]=(char*)malloc(20+1);

                     printf("Enter fname the student %d:",noRecords);

                     scanf("%s",fname+noRecords);

                     lname[noRecords]=(char*)malloc(20+1);

                     printf("Enter lname of the student %d:",noRecords);

                     scanf("%s",lname+noRecords);

                           noRecords++;

                     break;

       case 3:       printf("Enter the last name of the student:");

                     name=(char*)malloc(20+1);

                     scanf("%s",name);

                     for(int i=0;i<noRecords;i++)

                     {

                           if(name==lname[i])

                           {

                                  free(lname[i]);

                                  free(fname[i]);

                                  free(score[i]);

                           }

                     }

                     break;

       case 0:printf("exiting..");exit(0); break;

       default: printf(" Invalid choice ");

       }

       }while(1);

       

       }

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