Student Data Management in C++A simple C++ application called Student Management System is used by educational institutions to handle student data and many other data requirements related to students in a school. User can create, view and edit content in this student management system project. Nowadays, databases are used in every part of our lives. Servers around the world contain trillions of bytes of data. One of the easiest ways to use such a database is with SQL. However, have you ever considered using C++ to manage such a database. In this article, we will discuss how to create multiple views of a text file based on the type of user and adjust accordingly. This code stores the following information:
Program BreakdownWe are including all the necessary libraries in this program to avoid any kind of compile error. We are considering the maximum length of the data entered to be 15. And ifstream accessing the file "Example.txt" in which DB is sorted. The above for loop is used to count the number of lines in the file. The while loop above will only execute when the option selected is not equal to 6 and printing line by line the available operations, add new student, student login, faculty login, proctor login, admin view, exit for 6th option and entering the option. The above peace of code will come in executing only when the user chooses 1 as the option. In this, it will ask the user to enter the number of student. The entire data of the student will be stored line by line, and then it will ask to enter the registration number and enter the name. In the above demonstrated peace of code the else if loop will executed when the user will choose the 2 as the second option. The registration number has size of 9 characters and ask user to enter the registration number then it will display the Registration Number. Further it will ask for the marks in subject. If a user has chosen 0 as an option it will display that No such registration Number found. Above else if loop will execute only when the user has selected the 3rd option. In this, the user will be asked to enter the subject code, Available Operations and to view data. Basically this loop is used to view or add marks to the student database. In the above peace of code, if the user has selected the option 1, it will show a message that warning you need to add marks; The seek in file has been done according to the length of the data being inserted. It needs to adjust accordingly for different lengths of data. In the above peace of code the else loop will only execute when the user has selected option 2. This loop is used to view marks of a student. The extra infile commands have been used to get a specific mark only since the data has been separated by a tabspace. In the above peace of code, loop displays all the details of students under the same proctor ID. This loop acts as an admin view to see all the data in the file. This variable value can be changed according to your requirement of the administrator password. Student Database Management Program in C++Output: Available operations: 1. Add New Students 2. Student Login 3. Faculty Login 4. Proctor Login 5. Admin View 6. Exit Enter option: 1 Enter the number of students: 2 Enter your registration number: 12BCE2083 Enter your name: Prateek Enter your proctor ID: 10001 Enter your registration number: 15BCE2022 Enter your name: shubham Enter your proctor ID: 10002 Available operations: 1. Add New Students 2. Student Login 3. Faculty Login 4. Proctor Login 5. Admin View 6. Exit Enter option: 3 Enter your subject code: CSE10001 Available operations: 1. Add data about marks 2. View data Enter option: 1 Warning! You would need to add mark details for all the students! Enter the mark of student#1 : 54 Enter the mark of student#2 : 90 No such subject code found! Available operations: 1. Add New Students 2. Student Login 3. Faculty Login 4. Proctor Login 5. Admin View 6. Exit Enter option: 5 Enter the admin password: admin Reg No. Name CSE1001 CSE1002 Proctor ID 15BCE2083 Prateek 54 00 10001 15BCE2082 Shubham 89 00 10002 Available operations: 1. Add New Students 2. Student Login 3. Faculty Login 4. Proctor Login 5. Admin View 6. Exit Enter option: 6 - - - - - - - - - - - - - - - - - - - - - - - (Program exited with code: 0) Press return to continue NOTE: Please note that the pointer position has been adjusted to reflect the length of the data we are adding to the text file. We have assumed a registration number that is always 9 characters long, a subject code that is either CSE10001 or CSE10002, a proctor ID that is 4 characters long, and tags that are only 2 characters long. If you wanted to enter a different type of data, you would have to modify the code accordingly.Next TopicTic-Tac-Toe in C++ |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India