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

School Managment System

The document is a C++ program for a School Management System that allows users to add, view, and search for student records. It defines a Student structure and provides functions for managing student data, with a menu-driven interface for user interaction. The program supports a maximum of 100 students and includes error handling for exceeding this limit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views5 pages

School Managment System

The document is a C++ program for a School Management System that allows users to add, view, and search for student records. It defines a Student structure and provides functions for managing student data, with a menu-driven interface for user interaction. The program supports a maximum of 100 students and includes error handling for exceeding this limit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Shumail Abbas

B24F1260AI050
Shahyan Khan
b24f1000ai276
M rabee
b24f1204ai002
Aeman awais
b24f0897ai007
#include <iostream>
#include <string>
using namespace std;

const int MAX_STUDENTS = 100;

struct Student {
int rollNo;
string name;
int age;
string grade;
};

void addStudent(Student students[], int &count);


void viewStudents(const Student students[], int count);
void searchStudent(const Student students[], int count);

int main() {
Student students[MAX_STUDENTS];
int studentCount = 0;
int choice;
do {
cout << "\n===== School Management System =====" << endl;
cout << "1. Add Student" << endl;
cout << "2. View All Students" << endl;
cout << "3. Search Student by Roll Number" << endl;
cout << "4. Exit" << endl;
cout << "Enter your choice: ";
cin >> choice;

switch (choice) {
case 1:
addStudent(students, studentCount);
break;
case 2:
viewStudents(students, studentCount);
break;
case 3:
searchStudent(students, studentCount);
break;
case 4:
cout << "Exiting the program. Goodbye!" << endl;
break;
default:
cout << "Invalid choice. Please try again." << endl;
}
} while (choice != 4);

return 0;
}
void addStudent(Student students[], int &count) {
if (count >= MAX_STUDENTS) {
cout << "Error: Cannot add more students. Maximum limit reached." << endl;
return;
}

cout << "\nEnter Roll Number: ";


cin >> students[count].rollNo;
cin.ignore();
cout << "Enter Name: ";
getline(cin, students[count].name);
cout << "Enter Age: ";
cin >> students[count].age;
cin.ignore();
cout << "Enter Grade: ";
getline(cin, students[count].grade);

count++;
cout << "Student added successfully!" << endl;
}

void viewStudents(const Student students[], int count) {


if (count == 0) {
cout << "No students to display." << endl;
return;
}

cout << "\n===== Student Records =====" << endl;


for (int i = 0; i < count; i++) {
cout << "Roll Number: " << students[i].rollNo << endl;
cout << "Name: " << students[i].name << endl;
cout << "Age: " << students[i].age << endl;
cout << "Grade: " << students[i].grade << endl;
cout << "---------------------------" << endl;
}
}

void searchStudent(const Student students[], int count) {


if (count == 0) {
cout << "No students to search." << endl;
return;
}

int rollNo;
cout << "\nEnter Roll Number to search: ";
cin >> rollNo;

for (int i = 0; i < count; i++) {


if (students[i].rollNo == rollNo) {
cout << "\nStudent Found!" << endl;
cout << "Roll Number: " << students[i].rollNo << endl;
cout << "Name: " << students[i].name << endl;
cout << "Age: " << students[i].age << endl;
cout << "Grade: " << students[i].grade << endl;
return;
}
}

cout << "Student with Roll Number " << rollNo << " not found." << endl;
}

You might also like