Program to store the information about three students.
Source Code:
#include <stdio.h>
struct student {
char Name[50];
int roll;
float marks[3];
} s[3];
int main() {
int i;
printf("Enter information of students:\n");
for (i = 0; i < 3; ++i) {
s[i].roll = i + 1;
printf("\nFor roll number%d,\n", s[i].roll);
printf("Enter name: ");
scanf("%s", s[i].Name);
printf("Enter 3 subjects marks: ");
for (int j = 0; j < 3; j++) {
scanf("%f", &s[i].marks[j]);
}
}
printf("Displaying Information:\n\n");
for (i = 0; i < 3; ++i) {
printf("\nRoll number: %d\n", i + 1);
printf("First name: \n");
puts(s[i].Name);
for (int j = 0; j < 3; j++) {
printf("Marks: %.1f\n", s[i].marks[j]);
}
printf("\n");
}
return 0;
}
Output:
Enter name: xyz
Enter 3 subjects marks: 90
96
93
Enter name: pqr
Enter 3 subjects marks: 89
90
91
96
93
90
91
No comments:
Post a Comment