| ➕ Add Student | 📋 Display All | 🏆 Find Topper | 📊 Auto Totals | 📈 Averages | 🚪 Exit |
|---|---|---|---|---|---|
| Add student name and marks for 3 subjects | Display all students in a formatted table | Automatically find and display the top scorer | Auto-calculate total marks per student | Auto-calculate average marks per student | Graceful exit with goodbye message |
=== Student Marks Management ===
1. Add Student
2. Display All Students
3. Find Topper
4. Exit
Choose an option (1-4): 1
Enter student name: safin
Enter marks for subject 1 : 12
Enter marks for subject 2 : 12
Enter marks for subject 3 : 12
Student 'safin' added successfully!
=== Student Marks Management ===
Choose an option (1-4): 2
Name Marks (Sub1 Sub2 Sub3) Total Average
----------------------------------------------------
safin 12 12 12 Total: 36 Average: 12.00
=== Student Marks Management ===
Choose an option (1-4): 4
Goodbye! Exiting program.
struct Student {
char name[50];
float marks[3]; // marks for 3 subjects
float total;
float average;
};void addStudent(struct Student s[], int *count) {
printf("Enter student name: ");
scanf("%s", s[*count].name);
float total = 0;
for (int i = 0; i < 3; i++) {
printf("Enter marks for subject %d : ", i + 1);
scanf("%f", &s[*count].marks[i]);
total += s[*count].marks[i];
}
s[*count].total = total;
s[*count].average = total / 3.0;
(*count)++;
printf("Student '%s' added successfully!\n", s[*count - 1].name);
}void displayAll(struct Student s[], int count) {
printf("%-10s Marks (Sub1 Sub2 Sub3) Total Average\n", "Name");
printf("----------------------------------------------------\n");
for (int i = 0; i < count; i++) {
printf("%-10s %.0f %.0f %.0f Total: %.0f Average: %.2f\n",
s[i].name,
s[i].marks[0], s[i].marks[1], s[i].marks[2],
s[i].total, s[i].average);
}
}void findTopper(struct Student s[], int count) {
int top = 0;
for (int i = 1; i < count; i++) {
if (s[i].total > s[top].total)
top = i;
}
printf("Topper: %s with Total: %.0f Average: %.2f\n",
s[top].name, s[top].total, s[top].average);
}- Linux OS
- GCC installed
# Check GCC
gcc --version
# Install if needed (Ubuntu/Debian)
sudo apt install gccgcc -o student_marks "(PROJECT)_Student_Marks_Management_System.c" -lm
⚠️ The-lmflag links the math library — required for average calculations
./student_marksgcc -o student_marks "(PROJECT)_Student_Marks_Management_System.c" -lm && ./student_marksProject-C-Student-Marks-Management/
│
├── 📄 (PROJECT)_Student_Marks_Management_System.c ← Full source code
└── 📄 README.md ← Project documentation
┌──────────────────────────────────────────────────┐
│ C Console Application │
├─────────────────┬────────────────────────────────┤
│ Language │ C (C99 standard) │
│ Compiler │ GCC with -lm flag (Linux) │
│ Editor │ VS Code │
│ Libraries │ stdio.h · stdlib.h · math.h │
│ Platform │ Linux │
└─────────────────┴────────────────────────────────┘
struct → custom data type for Student records
arrays → store marks for 3 subjects per student
for loop → iterate over students and subjects
printf %-10s → left-aligned formatted table output
total / 3.0 → calculate average marks
linear search → find topper by comparing totals
scanf/printf → console input and output
-lm flag → link math library at compile time
Saharia Hassan Safin C Developer · Front-end Developer
"Every student deserves a topper finder built just for them" 🎓