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

You are given a student data file which consists of the student\'s name, student

ID: 3785093 • Letter: Y

Question

You are given a student data file which consists of the student's name, student ID, and GPA. Data set is provided below:

            Name             ID                    GPA

             Alice              8234               2.7
            Mark               2672               3.0
            Joanne          1234               3.7
            John               3291               2.0
             Tim                 3212               3.8
            Alford             1034               2.7
            Benson          6290               2.5
            Nancy            4234               3.7
            Oscar              1672               1.0
            Larry               1004               2.7


1) Write a program to process this student data. First, input these records into a record structure. Then, sort them in ascending order using Student ID as a key. Display the sorted output.
2) Remove the record with the Student ID = 4234.
3) Add a new record. Name = “Wilson”, Student ID = 3232, GPA = 3.1
4) Then, sort them again in ascending order using Student ID as a key. Display the sorted output.


You are limited to use ONLY the concepts of one dimension array and record (struct).

Explanation / Answer

//1 question 2nd part answer

include <stdio.h>

int main()

{

    int arr[MAX],limit;

    int i,j,temp;

     

    printf("Enter total number of elements: ");

    scanf("%d",&limit);

     

    /*Read array*/

    printf("Enter array elements: ");

    for(i=0; i<limit; i++)

    {

        printf("Enter element %3d: ",i+1);

        scanf("%d",&arr[i]);

    }

     

    /*sort elements in Ascending Order*/

    for(i=0; i<(limit-1); i++)

    {

        for(j=0; j<(limit-i-1); j++)

        {

            if(arr[j]>arr[j+1])

            {

                temp=arr[j];

                arr[j]=arr[j+1];

                arr[j+1]=temp;

            }

        }

    }

    printf("Array elements in Ascending Order")

    for(i=0; i<limit; i++)

        printf("%d ",arr[i])

     

    printf(" ");

return 0;

}

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