From bf34bbde635fbfb21f1d490f34a7b3462c9b5b51 Mon Sep 17 00:00:00 2001 From: koushithatadiboina Date: Tue, 25 Nov 2025 20:56:29 +0530 Subject: [PATCH] Create StudentReport-C This PR adds a simple C program to create a student report card system. It allows input of student name, roll number, and marks for 5 subjects. The program calculates total marks and percentage, and displays a formatted report card. It is beginner-friendly and suitable for learning basic C programming and structures. Please review and merge. Thank you! --- StudentReport-C | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 StudentReport-C diff --git a/StudentReport-C b/StudentReport-C new file mode 100644 index 0000000..34732e0 --- /dev/null +++ b/StudentReport-C @@ -0,0 +1,52 @@ +#include +#include +#define MAX 50 + +struct Student { + char name[50]; + int roll; + int marks[5]; + int total; + float percentage; +}; + +void calculate(struct Student* s) { + s->total = 0; + for (int i = 0; i < 5; i++) { + s->total += s->marks[i]; + } + s->percentage = s->total / 5.0; +} + +void display(struct Student s) { + printf("\n--- Report Card ---\n"); + printf("Name: %s\n", s.name); + printf("Roll Number: %d\n", s.roll); + printf("Marks: "); + for (int i = 0; i < 5; i++) { + printf("%d ", s.marks[i]); + } + printf("\nTotal: %d\n", s.total); + printf("Percentage: %.2f%%\n", s.percentage); +} + +int main() { + struct Student s; + + printf("Enter student name: "); + fgets(s.name, sizeof(s.name), stdin); + s.name[strcspn(s.name, "\n")] = 0; // remove newline + + printf("Enter roll number: "); + scanf("%d", &s.roll); + + printf("Enter marks for 5 subjects: "); + for (int i = 0; i < 5; i++) { + scanf("%d", &s.marks[i]); + } + + calculate(&s); + display(s); + + return 0; +}