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

In this project we would like to write a C program that manages students\' recor

ID: 3836730 • Letter: I

Question

In this project we would like to write a C program that manages students' records. A student can be described by the following fields: Student ID Student last name Student last name Grade Major you need to use hierarchical structure to implement the structure of a student. Crate a structure, called name for example, that declares first name and last name. Here are the input records for your programs: 1. 1001 Clock Explosion A CS 2. 1002 Van Gogh C EE 3. 1003 Paul Michelangelo B Stat 4. 1004 Salvador Dali D Eco 5. 1005 William Joe B Eco 6. 1006 Mary Raphael C Math 7. 1007 John Scher A Mec 8. 1008 Rahul Patel B Eco 9. 1009 Claude Monet C CS 10. 1010 Gustav Klimt A CS

Explanation / Answer

#include<stdio.h>
#include<conio.h>
/* Structure for name */
struct NAME
{
   char firstName[20];
   char lastName[20];
};

/* Structure for Student */
struct STUDENT
{
   int ID;
   struct NAME name;
   char grade;
   char major[10];
};

/*Function to print Details of one student */
void printDetails(struct STUDENT s)
{
   printf("%d %-11s %-11s %-11c %-11s ",s.ID,s.name.firstName,s.name.lastName,s.grade,s.major);
}

/* Function to print details of all students */
void printAll(struct STUDENT s[])
{
   int i=0;
   for(i=0;i<10;i++)
   {
       printDetails(s[i]);
   }
}

/* Function to print details of all students by a specific department */
void printByDept(char dept[],struct STUDENT s[])
{
   int i=0;
   for(i=0;i<10;i++)
   {
       if(strcmp(dept,s[i].major)==0)
       {
           printDetails(s[i]);
       }
   }
}

/* Function to print details of all students by a specific grade */
void printByGrade(char grade,struct STUDENT s[])
{
   int i=0;
   for(i=0;i<10;i++)
   {
       if(grade == s[i].grade)
       printDetails(s[i]);
   }
}

/* Function to print details of all students with a given ID */
void printByID(int ID,struct STUDENT s[])
{
   int i=0;
   for(i=0;i<10;i++)
   {
       if(ID == s[i].ID)
       printDetails(s[i]);
   }
}

void main()
{
   char g;
   int ID,ch;
   /* Initialize the structure members */
   struct STUDENT stdnts[10] = {{1001,"Clock","Explosion",'A',"CS"},
                               {1002,"Van","Gogh",'C',"EE"},
                               {1003,"Paul","Michelangelo",'B',"Stat"},
                               {1004,"Salvador","Dali",'D',"Eco"},
                               {1005,"William","Joe",'B',"Eco"},
                               {1006,"Mary","Raphael",'C',"Math"},
                               {1007,"John","Scher",'A',"Mec"},
                               {1008,"Rahul","Patel",'B',"Eco"},
                               {1009,"Claude","Monet",'C',"CS"},
                               {1010,"Gustav","Klimt",'A',"CS"}};
   clrscr();

   /* Print details of all students in CS department */
   printf("******Students in CS department are as follows:***** ");
   printByDept("CS",stdnts);

   /* Print details of all students in Eco */
   printf("******Students in Eco are as follows:****** ");
   printByDept("Eco",stdnts);

   /* Display the details of all students as required */
   do
   {
       printf("Enter your choice: ");
       printf("1.Display By Grade 2.Display By ID 3.Display All 4.Exit ");
       scanf(" %d",&ch);

       switch(ch)
       {
           case 1:   printf("Enter the grade: ");
                   scanf(" %c",&g);
                   printf("******Students with grade %c are as follows:****** ",g);
                   printByGrade(g,stdnts);
                   break;

           case 2:   printf("Enter ID: ");
                   scanf("%d",&ID);
                   printf("******Student with %d is as follows****** ",ID);
                   printByID(ID,stdnts);
                   break;

           case 3:   printAll(stdnts);
                   break;

           case 4: exit(0);
                   break;
       }
   }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