In this program, I will tell you how to make a program that will store roll number, name and marks of 5 subjects. Program will print these later on.
Source code:
Source code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #include<stdio.h> #include<conio.h> struct student { int roll_no; char name[15]; int marks[5]; }; int main() { struct student stu[4]; int i, j; printf("We will collect roll number, name and marks of 4 students and print them. "); for(i=0; i<4; i++) { printf("\nenter roll number of student: "); scanf("%d",&stu[i].roll_no); printf("enter name: "); scanf("%s",&stu[i].name); printf("enter marks of this student:"); for(j=0; j<5; j++) { scanf("%d",&stu[i].marks[j]); } } for(i=0; i<4; i++) { printf("\n Name: %s \n Roll No: %d\n", stu[i].name, stu[i].roll_no); printf("Marks:"); for(j=0;j<5;j++) { printf("\t %d", stu[i].marks[j]); } } } |
Here is the source code of this program.
If you have any question regarding this code. Ask in comments.
कोई टिप्पणी नहीं:
एक टिप्पणी भेजें