0% found this document useful (0 votes)
16 views5 pages

Prashantproject

The document outlines a fully functional school management system implemented in C, which includes features for adding, finding, deleting, and updating student records. It defines a structure for student details, allowing multiple course registrations, and provides a menu-driven interface for user interaction. Key functions include adding students, searching by roll number or first name, counting students, and managing course enrollments.

Uploaded by

46prashant46
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)
16 views5 pages

Prashantproject

The document outlines a fully functional school management system implemented in C, which includes features for adding, finding, deleting, and updating student records. It defines a structure for student details, allowing multiple course registrations, and provides a menu-driven interface for user interaction. Key functions include adding students, searching by roll number or first name, counting students, and managing course enrollments.

Uploaded by

46prashant46
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/ 5

‭ ROJECT:Fully functional school management system‬

P
‭Source code:‬
‭ include <stdio.h>‬
#
‭#include <string.h>‬
‭#define MAX_STUDENTS 100‬
‭#define MAX_COURSES 5‬
‭#define MAX_NAME_LEN 50‬
‭// Define the structure for student details‬
‭typedef struct {‬
‭int roll_no;‬
‭char first_name[MAX_NAME_LEN];‬
‭char last_name[MAX_NAME_LEN];‬
‭char courses[MAX_COURSES][MAX_NAME_LEN]; // A student can register in multiple courses‬
‭int course_count; // Number of courses the student is registered in‬
‭} Student;‬
‭// Array of students to hold the student records‬
‭Student students[MAX_STUDENTS];‬
‭int student_count = 0; // Tracks the number of students in the system‬
‭// Function to add a new student‬
‭void addStudent() {‬
‭if (student_count >= MAX_STUDENTS) {‬
‭printf("Student limit reached! Cannot add more students.\n");‬
‭return;‬
‭}‬
‭Student new_student;‬
‭printf("Enter Roll Number: ");‬
‭scanf("%d", &new_student.roll_no);‬
‭getchar(); // To consume the newline character left by scanf‬
‭printf("Enter First Name: ");‬
‭fgets(new_student.first_name, MAX_NAME_LEN, stdin);‬
‭new_student.first_name[strcspn(new_student.first_name, "\n")] = '\0'; // Remove newline‬
‭printf("Enter Last Name: ");‬
‭fgets(new_student.last_name, MAX_NAME_LEN, stdin);‬
‭new_student.last_name[strcspn(new_student.last_name, "\n")] = '\0'; // Remove newline‬
‭printf("Enter number of courses the student is registered for: ");‬
‭scanf("%d", &new_student.course_count);‬
‭getchar(); // Consume newline‬
‭for (int i = 0; i < new_student.course_count; i++) {‬
‭printf("Enter course %d name: ", i + 1);‬
‭fgets(new_student.courses[i], MAX_NAME_LEN, stdin);‬
‭new_student.courses[i][strcspn(new_student.courses[i], "\n")] = '\0'; // Remove newline‬
‭}‬
‭students[student_count++] = new_student;‬
‭printf("Student added successfully.\n");‬
‭}‬
‭// Function to find a student by roll number‬
‭void findStudentByRollNo(int roll_no) {‬
‭for (int i = 0; i < student_count; i++) {‬
‭if (students[i].roll_no == roll_no) {‬
‭printf("Student Found: Roll No: %d, Name: %s %s\n", students[i].roll_no, students[i].first_name,‬
‭students[i].last_name);‬
‭printf("Courses enrolled: ");‬
‭for (int j = 0; j < students[i].course_count; j++) {‬
‭printf("%s ", students[i].courses[j]);‬
‭}‬
‭printf("\n");‬
‭return;‬
‭}‬
‭}‬
‭printf("Student with roll number %d not found.\n", roll_no);‬
‭}‬
‭// Function to find students by first name‬
‭void findStudentsByFirstName(const char* first_name) {‬
‭int found = 0;‬
‭for (int i = 0; i < student_count; i++) {‬
‭if (strcmp(students[i].first_name, first_name) == 0) {‬
‭printf("Student Found: Roll No: %d, Name: %s %s\n", students[i].roll_no, students[i].first_name,‬
‭students[i].last_name);‬
‭printf("Courses enrolled: ");‬
‭for (int j = 0; j < students[i].course_count; j++) {‬
‭printf("%s ", students[i].courses[j]);‬
‭}‬
‭printf("\n");‬
‭found = 1;‬
‭}‬
‭}‬
‭if (!found) {‬
‭printf("No student found with the first name '%s'.\n", first_name);‬
‭}‬
‭}‬
‭// Function to find students enrolled in a course‬
‭void findStudentsInCourse(const char* course_name) {‬
‭int found = 0;‬
‭for (int i = 0; i < student_count; i++) {‬
‭for (int j = 0; j < students[i].course_count; j++) {‬
‭if (strcmp(students[i].courses[j], course_name) == 0) {‬
‭printf("Student Found: Roll No: %d, Name: %s %s\n", students[i].roll_no, students[i].first_name,‬
‭students[i].last_name);‬
‭found = 1;‬
‭break; // No need to check further courses for this student‬
‭}‬
‭}‬
‭}‬
‭if (!found) {‬
‭printf("No students found in the course '%s'.\n", course_name);‬
‭}‬
‭}‬
/‭/ Function to count the number of students‬
‭void countStudents() {‬
‭printf("Total number of students: %d\n", student_count);‬
‭}‬
‭// Function to delete a student by roll number‬
‭void deleteStudent(int roll_no) {‬
‭int found = 0;‬
‭for (int i = 0; i < student_count; i++) {‬
‭if (students[i].roll_no == roll_no) {‬
‭for (int j = i; j < student_count - 1; j++) {‬
‭students[j] = students[j + 1]; // Shift students left to delete‬
‭}‬
‭student_count--;‬
‭printf("Student with roll number %d deleted successfully.\n", roll_no);‬
‭found = 1;‬
‭break;‬
‭}‬
‭}‬
‭if (!found) {‬
‭printf("Student with roll number %d not found.\n", roll_no);‬
‭}‬
‭}‬
‭// Function to update student details by roll number‬
‭void updateStudent(int roll_no) {‬
‭for (int i = 0; i < student_count; i++) {‬
‭if (students[i].roll_no == roll_no) {‬
‭printf("Enter new First Name: ");‬
‭fgets(students[i].first_name, MAX_NAME_LEN, stdin);‬
‭students[i].first_name[strcspn(students[i].first_name, "\n")] = '\0'; // Remove newline‬
‭printf("Enter new Last Name: ");‬
‭fgets(students[i].last_name, MAX_NAME_LEN, stdin);‬
‭students[i].last_name[strcspn(students[i].last_name, "\n")] = '\0'; // Remove newline‬
‭printf("Enter number of courses the student is registered for: ");‬
‭scanf("%d", &students[i].course_count);‬
‭getchar(); // Consume newline‬
‭for (int j = 0; j < students[i].course_count; j++) {‬
‭printf("Enter course %d name: ", j + 1);‬
‭fgets(students[i].courses[j], MAX_NAME_LEN, stdin);‬
‭students[i].courses[j][strcspn(students[i].courses[j], "\n")] = '\0'; // Remove newline‬
‭}‬
‭printf("Student details updated successfully.\n");‬
‭return;‬
‭}‬
‭}‬
‭printf("Student with roll number %d not found.\n", roll_no);‬
‭}‬
‭// Main Menu‬
‭void showMenu() {‬
‭printf("\nSchool Management System\n");‬
‭ rintf("1. Add Student\n");‬
p
‭printf("2. Find Student by Roll No\n");‬
‭printf("3. Find Student by First Name\n");‬
‭printf("4. Find Students by Course\n");‬
‭printf("5. Count Students\n");‬
‭printf("6. Delete Student\n");‬
‭printf("7. Update Student\n");‬
‭printf("8. Exit\n");‬
}‭ ‬
‭int main() {‬
‭int choice;‬
‭while (1) {‬
‭showMenu();‬
‭printf("Enter your choice: ");‬
‭scanf("%d", &choice);‬
‭switch (choice) {‬
‭case 1:‬
‭addStudent();‬
‭break;‬
‭case 2: {‬
‭int roll_no;‬
‭printf("Enter Roll Number to search: ");‬
‭scanf("%d", &roll_no);‬
‭findStudentByRollNo(roll_no);‬
‭break;‬
‭}‬
‭case 3: {‬
‭char first_name[MAX_NAME_LEN];‬
‭printf("Enter First Name to search: ");‬
‭getchar(); // Consume newline‬
‭fgets(first_name, MAX_NAME_LEN, stdin);‬
‭first_name[strcspn(first_name, "\n")] = '\0'; // Remove newline‬
‭findStudentsByFirstName(first_name);‬
‭break;‬
‭}‬
‭case 4: {‬
‭char course_name[MAX_NAME_LEN];‬
‭printf("Enter Course Name to search: ");‬
‭getchar(); // Consume newline‬
‭fgets(course_name, MAX_NAME_LEN, stdin);‬
‭course_name[strcspn(course_name, "\n")] = '\0'; // Remove newline‬
‭findStudentsInCourse(course_name);‬
‭break;‬
‭}‬
‭case 5:‬
‭countStudents();‬
‭break;‬
‭case 6: {‬
‭int roll_no;‬
‭ rintf("Enter Roll Number to delete: ");‬
p
‭scanf("%d", &roll_no);‬
‭deleteStudent(roll_no);‬
‭break;‬
‭}‬
‭}‬
‭}‬
‭}‬

You might also like