0% found this document useful (0 votes)
27 views2 pages

#Include #Include #Include

This C program defines structures to store student and subject details. It takes input from the user like student name, enrollment number, subjects and marks. It calculates the grade for each subject based on the marks and total marks. Finally, it prints the student result slip with name, subjects, marks, grades and an overall remark of pass or fail.

Uploaded by

Amit Rawlani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

#Include #Include #Include

This C program defines structures to store student and subject details. It takes input from the user like student name, enrollment number, subjects and marks. It calculates the grade for each subject based on the marks and total marks. Finally, it prints the student result slip with name, subjects, marks, grades and an overall remark of pass or fail.

Uploaded by

Amit Rawlani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1: #include<stdio.

h>
2: #include<stdlib.h>
3: #include<string.h>
4:
5: struct subject_marks{
6: char subject_code[10];
7: char subject_name[25];
8: int marks_obtained;
9: char grade;
10: };
11:
12: struct student{
13: char name[25];
14: char enroll_no[8];
15: char roll_no[10];
16: char father_name[25];
17: int sem;
18: int year;
19: char course[40];
20: struct subject_marks result[6];
21: int total_marks_obtained;
22: };
23:
24: char get_grade(int marks);
25: void print_result(struct student s);
26:
27:
28:
29: int main(){
30:
31: struct student s;
32: int i;
33:
34: printf("Enter the name of the student: ");
35: gets(s.name);
36: printf("Enter the course: ");
37: gets(s.course);
38: printf("Enter Enrollment number of %s: ",s.name);
39: gets(s.enroll_no);
40: printf("Enter Roll number of %s: ",s.name);
41: gets(s.roll_no);
42: printf("Enter Father's name of %s: ",s.name);
43: gets(s.father_name);
44: printf("Enter Semester: ");
45: scanf("%d",&s.sem);
46: printf("Enter Year: ");
47: scanf("%d",&s.year);
48:
49: printf("\nEnter Subject and Marks details:\n");
50:
51: for(i=0;i<6;i++){
52: printf("\nEnter the Subject code: ");
53: fflush(stdin);
54: gets(s.result[i].subject_code);
55: printf("Enter the Subject name: ");
56: gets(s.result[i].subject_name);
57: printf("Enter the marks obtained in %s: ",s.result[i].subject_name);
58: scanf("%d",&s.result[i].marks_obtained);
59: s.total_marks_obtained = s.total_marks_obtained + s.result[i].marks_obtained;
60: s.result[i].grade = get_grade(s.result[i].marks_obtained);
61: }
62:
63:
64: print_result(s);
65: return 0;
66: }
67:
68:
69:
70: char get_grade(int marks_obtained){
71: if(marks_obtained>=75)
72: return 'A';
73: else if(marks_obtained>=60)
74: return 'B';
75: else if(marks_obtained>=40)
76: return 'C';
77: else
78: return 'F';
79: }
80:
81: void print_result(struct student s){
82: int j;
83: char remark[10];
84: printf("\n\n\n\n\n\t\t\t\t\tJAMIA MILLIA ISLAMIA");
85: printf("\n\t\t\t\t%s",s.course);
86: printf("\n\t\t\t\tSemester: %d",s.sem);
87: printf("\t\tYear: %d",s.year);
88: printf("\n\nName of the Candidate: %-25s\t\tEnrollment No.: %s",s.name,
s.enroll_no);
89: printf("\nFather's name: %-25s\t\t\tRoll No.: %s",s.father_name,s.roll_no);
90: printf("\n\nSubject code\t\tSubject Name\t\t\tTotal Marks\t\tMarks
Obtained\t\tGrade\n");
91: for(j=0;j<6;j++){
92: printf("\n%-10s\t\t%-25s\t\t100\t\t\t%d\t\t\t%c",s.result[j].subject_code,
s.result[j].subject_name,s.result[j].marks_obtained,s.result[j].grade);
93: }
94:
95: if(s.total_marks_obtained>=(0.4*300))
96: strcpy(remark,"PASSED");
97: else
98: strcpy(remark,"FAILED");
99:
100: printf("\n\n\t\t\tRemarks: %s",remark);
101:
102: }

You might also like