In: Electrical Engineering
Question 6: Recommend/ Explain
a program that takes the information of 40 students in following
order
Name:
Father Name:
Enrollment number:
Date of birth:
After taking the information of the students, it then displays the entered information.
Code in C Language (using structures) :
#include <stdio.h>
struct student {
char Stud_Name[20];
char Father_Name[20];
int Enroll_num;
char DOB[20];
} s[40];
int main() {
int i;
printf("Enter information of students:\n");
// storing information
for (i = 0; i < 40; ++i) {
printf("Record number - %d",i+1);
printf("\nEnter Student Name: ");
scanf("%s", s[i].Stud_Name);
printf("Enter Father Name : ");
scanf("%s", s[i].Father_Name);
printf("Enter Enrollment Number :");
scanf("%d", &s[i].Enroll_num);
printf("Enter DOB(example:04-06-1999) : ");
scanf("%s", s[i].DOB);
printf("\n");
}
printf("Displaying Information:\n\n");
// displaying information
for (i = 0; i < 40; ++i) {
printf("Record number - %d",i+1);
printf("\nStudent Name: ");
puts(s[i].Stud_Name);
printf("Father Name :");
puts(s[i].Father_Name);
printf("Enrollment Number :");
printf("%d",s[i].Enroll_num);
printf("\nDate of birth :");
puts(s[i].DOB);
printf("\n");
}
return 0;
}