In: Computer Science
1. To understand the value of records in a programming language, write a small program in a C-based language that uses an array of structs that store student information, including name, age, GPA as a float, and grade level as a string (e.g., “freshmen, junior, senior” etc.). Also, write the same program in the same language without using structs.
Note: Code and with output screenshots
#include<stdio.h>
#include<string.h>
//struct to store student info
struct student
{
   char name[20];
   int age;
   float GPA;
   char grade_level[20];  
};
int main()
{
   //now creating array of structs to store student
data;
   struct student s[2];//to store two student
details
   strcpy(s[0].name,"Surya");
   s[0].age=24;
   s[0].GPA=8;
   strcpy(s[0].grade_level,"Senior");
   strcpy(s[1].name,"Gopi");
   s[1].age=23;
   s[1].GPA=7;
   strcpy(s[1].grade_level,"Junior");
   //displaying output
   printf("Using structs\n");
   for(int i=0;i<2;i++)
   {
       printf("Student %d
details",i+1);  
      
printf("Name:%s\nAge:%d\nGPA:%f\nGrade_level:%s\n",s[i].name,s[i].age,s[i].GPA,s[i].grade_level);
   }
  
   //now with out using structs
   char name[2][20];
   int age[2];
   float GPA[2];
   char grade_level[2][20];
   //storing data
  
   strcpy(name[0],"Surya");
   age[0]=24;
   GPA[0]=8;
   strcpy(grade_level[0],"Senior");
   strcpy(name[1],"Gopi");
   age[1]=23;
   GPA[1]=7;
   strcpy(grade_level[1],"Junior");
  
   //displaying output
   printf("Without using structs\n");
       for(int i=0;i<2;i++)
   {
       printf("Student %d
details",i+1);  
      
printf("Name:%s\nAge:%d\nGPA:%f\nGrade_level:%s\n",name[i],age[i],GPA[i],grade_level[i]);
   }
  
   return 0;
}
output:
