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

C (NOT C++) 1) Write a program that creates a structure (a C struct) to hold stu

ID: 3859925 • Letter: C

Question

C (NOT C++) 1) Write a program that creates a structure (a C struct) to hold student information. The information should include Student number (let's use an int), Last Name, First Name, and Number of credits completed. The main program should allow the user to enter information on a student and then print out the information that was entered. 2) Write a program that allows the user to enter in multiple students (use the structure from problem 3 and create an array of students.) The program should then print the names and student number of all students with 128 credits or more. 3) Use the array of students from problem 4. The program should then enter a loop that allows the user to enter a student last name. The program should then print the remaining information for that student or students. The program should repeat this process until the user wants to quit.

Explanation / Answer


Ans 1)

#include <stdio.h>
struct student
{
    char last_name[30], first_name[30];
    int student_number;
    int credits;
} ;

int main()
{
       Struct student s;

       printf("Enter information of student: ");
  
   scanf("%d",s.student_number);
   scanf("%s",s.last_name);
   scanf("%s",s.first_name);
   scanf("%d",s.credits);
  
   Printf("Printing the entered information");
   printf("%d",s.student_number);
   printf("%s",s.last_name);
   printf("%s",s.first_name);
   printf("%d",s.credits);

   return 0;
}


Ans 2)

   int main()
{
   Struct student st[100];
   printf("Enter information of student: ");

       for(i=0; i<100; ++i)
       {
       scanf("%d",s[i].student_number);
       scanf("%s",s[i].last_name);
       scanf("%s",s[i].first_name);
       scanf("%d",s[i].credits);
   }


   printf("First name , last name and student number of student having credit more than 128: ");  
   for(i=0; i<100; ++i)
   {
       if(s[i].credits >= 128)
       {
           printf("%s %s %d",s[i].first_name,s[i].last_name,s[i].student_number);  
       }
   }
      
   return 0;  

}