APC-S-014.c (829B)
1 /* Write a program to store roll no, name and marks of 5 students then print it. use structure */ 2 3 #include <stdio.h> 4 #include <string.h> 5 6 struct student 7 { 8 int roll_no; 9 char name[30]; 10 float marks; 11 }; 12 13 int main() 14 { 15 int i, stu_count = 3; 16 struct student s[stu_count]; 17 for (i = 0; i < stu_count; i++) 18 { 19 printf("\nEnter the Roll Number: "); 20 scanf("%d", &s[i].roll_no); 21 getchar(); 22 printf("Enter the name: "); 23 gets(s[i].name); 24 printf("Enter the Marks: "); 25 scanf("%f", &s[i].marks); 26 } 27 printf("\n%-10s %-20s %-10s\n", "ROLL", "NAME", "MARKS"); 28 printf("%-10s %-20s %-10s\n", "====", "====", "====="); 29 for (i = 0; i < stu_count; i++) 30 { 31 printf("%-10d %-20s %-10.2f\n", s[i].roll_no, s[i].name, s[i].marks); 32 } 33 return 0; 34 }