## Student Record System in CIn this article, you will learn about a project which demonstrates how to build a Student Record System in C language. You will learn this concept through a single program which details all the functions happening in the entire process. ## What is Student Record System, and why should we use it?A simply generated database which stores all the details of the student, including the first name of the student, last name of the student, roll number of the student, CGPA of the student, courses registered by the student, etc. We need to use this in order to have secured student data and retrieve it whenever it is required. We are going to construct a program which is mainly based on switch cases and basic members of the programming language. The operations that can be performed using the Student record System are: - Add the Student details
- Retrieve the Student data with a roll number
- Retrieve the Student data with a first name
- Total number of Students registered in a particular course
- Delete a Student data
- Update a Student data
- Total number of Students
Let us split this entire software into fragments in which each fragment consists of a method describing one of those operations discussed above one by one sequentially. After finding the methods for all the operations listed, let us merge all of the discussed methods to form software that deals with and represents the Student Record System. This makes our work more accessible and understandable. ## 1. add_student():This method enables the addition of the details of a new Student. It gets the input data from the user and adds the same data into the Student record system by storing it within the system. It also checks the uniqueness of the roll number while adding the details of the Student, as the roll number of any student must be uniquely defined. Let us get into a program which details the method " add_student() ".
The method " add_student() " is considered in order to add the details of a new student. This is manually done by taking every detail as an input in their respective steps, and finally, the data is stored in the database of the system. According to the requirement, the variables are declared and initiated with an initial value. For example, the value of j is initialized with " 0 " as it must be iterated starting from the 0 The inputs are taken simply by scanning the values using " scanf ", and in order to print the list of few details, the iterations are made using loops. This is a simply generated method in which all the basic members, like loops, print statements, scan statements, etc., of the language are used. The inputs of the students' details are taken according to their data types. In this way, the working of the method " add_student() " is performed. ## 2. find_using_roll():This method is used to find the entire details of a specified student with their roll number as an input which is uniquely defined anyway. It takes the input of the roll number of the student in order to find the details of the student carrying that specified roll number ( through the input ). This is the main reason for giving unique roll numbers to each student so that their identity can be protected and the data can be retrieved easily just by using the roll number. Let us understand this concept through a program which details the method " find_using_roll() ".
The method " find_using_roll() " is declared a way different from the first method " add_student() ". Because the method " add_student() "takes an input of all the details of the student irrespective of the specification and adds the information of a new student. But, the method " find_using_roll() " takes the input of the roll number of the existing student and then finds all the details of the student based on the roll number given. All the process which involves entering the student details takes place in this method or function body. This is the difference between the methods " add_student() " and " find_using_roll() ". The base condition is taken as the roll number, and all the students' details are verified with the roll number. As soon as the match is found, the details of that particular student will be printed. The rest of the procedure followed in the program of the " find_using_roll() " method is quite the same as that of the " add_student() " method. In this way, the working of the method " find_using_roll() " is performed. ## 3. find_using_fname():This method is used to find the entire details of a specified student with their first name as input. So, the method " find_using_fname() " takes the input of the first name of the student in order to find the details of the student carrying that specified first name ( through the input ). Let us understand this concept through a program which details the " find_using_fname() " method.
The method " find_using_fname() " is declared a way different from the first method " add_student() " but similar to the method " find_using_roll() ". Because the method " add_student() "takes an input of all the details of the student irrespective of the specification and adds the information of a new student. All the process which involves entering the student details takes place in this method or function body. But, the method " find_using_roll() " takes the input of the roll number of the existing student and then finds all the details of the student based on the roll number given. In the same way, the method " find_using_fname() " takes the input of the first name of the existing student and then prints all details of that corresponding student. This is the major similarity between the methods " find_using_fname() " and " find_using_roll() ". The base condition is taken as the first name, and all the students' details are compared with that first name. As soon as the match is found, the details of that particular student will be printed. The rest of the procedure followed in the program of the " find_using_fname() " method is quite the same as that of the " add_student() " method and completely similar to that of the method " find_using_roll() ". In this way, the working of the method " find_using_fname() " is performed. ## 5. find_using_course():This method is used to find the details of the total students registered in a particular course with the course ID as input. So, the " find_using_course() " method takes the input of the course id and then prints all the details of the student who are enrolled in the course mentioned through the input. Let us understand this concept of finding the details through a program which details the method " find_using_fname() ".
The method " find_using_course() " is declared a way different from the first method " add_student() " but similar to the methods " find_using_roll() " and " find_using_fname() ". Because the method " add_student() "takes an input of all the details of the student irrespective of the specification and adds the information of a new student. All the process which involves entering the student details takes place in this method or function body. But, the method " find_using_roll() " takes the input of the roll number of the existing student and then finds all the details of the student based on the roll number given. In the same way, the method " find_using_fname() " takes the input of the first name of the existing student and then prints all details of that corresponding student, and the method " find_using_course() " takes the input of course id, finds the registered students, iterates over the details of the existing students and then prints all details of that corresponding students one by one. This quality is one of the major similarities between the methods " find_using_fname() ", " find_using_roll() " and " find_using_course ". The base condition is taken as the course id, and all the students' details are verified in order to find the relevant course id and are compared with that course id which is taken as input. As soon as the match is found, the details of those particular students who have registered or enrolled on that course will be printed. The same iteration takes place until the maximum number of students registered for that course is reached. In this way, the working of the method " find_using_course() " is performed. ## 5. delete():This method is used to delete the details of the student by referring to a roll number which is taken as an input. So, the " delete() " method takes the input of the roll number of the student whose data is supposed to be deleted and then deletes all the details or the data of the student who bares the roll number mentioned through the input. Let us understand this concept of finding the details through a program which details the method " delete() ".
The method " delete() " is declared in a way which is completely different from all the methods that are discussed and declared previously, i.e., the methods " add_student() ", " find_using_fname() ", " find_using_roll() " and " find_using_course() ". The method " add_student() "takes an input of all the details of the student irrespective of the specification and adds the information of a new student. All the process which involves entering the student details takes place in this method or function body. The method " find_using_roll() " takes the input of the roll number of the existing student and then finds all the details of the student based on the roll number given. In the same way, the method " find_using_fname() " takes the input of the first name of the existing student and then prints all details of that corresponding student, and the method " find_using_course() " takes the input of course id, finds the registered students, iterates over the details of the existing students and then prints all details of that corresponding students one by one. Whereas the method " delete() " deals with the deletion of the details of a particular student whose roll number is given as input by the user. This method helps in clearing the cache or the unwanted students' details. The base condition is taken as the roll, and all the students' details are verified in order to find the relevant roll number and are compared with that roll number which is taken as input. As soon as the match is found, the details of those particular students who have the required roll number will be deleted from the database. The same iteration takes place until the matching roll number is found. In this way, the working of the method " delete() " is performed. ## 6. update():This method is used to update the details of the student by referring to a roll number which is taken as an input. So, the" update() " method takes the input of the roll number of the student whose data is supposed to be updated and then updates all the details or the data of the student who bares the roll number mentioned through the input. Sometimes, you need not update all the details, but only some of the details should be updated. In such cases also, this method can be used. Let us understand this concept of finding the details through a program which details the method " update() ".
The method " update() " is declared in a way which is completely different from all the methods that are discussed and declared previously, i.e., the methods " add_student() ", " find_using_fname() ", " find_using_roll() ", " find_using_course() " and " delete() ". The method " add_student() "takes an input of all the details of the student irrespective of the specification and adds the information of a new student. All the process which involves entering the student details takes place in this method or function body. The method " find_using_roll() " takes the input of the roll number of the existing student and then finds all the details of the student based on the roll number given. In the same way, the method " find_using_fname() " takes the input of the first name of the existing student and then prints all details of that corresponding student, and the method " find_using_course() " takes the input of course id, finds the registered students, iterates over the details of the existing students and then prints all details of that corresponding students one by one. The method " delete() " deals with the deletion of the details of a particular student whose roll number is given as input by the user. Whereas the method " update() " deals with the updating of the details of a particular student whose roll number is given as input by the user. This method helps in having an up to date details of the students. In this method, the old details will be replaced and updated by the new details, and the new details will be asked to enter. The user will be given a choice in which we have to choose which detail he wishes to update. The base condition is taken as the roll, and all the students' details are verified in order to find the relevant roll number and are compared with that roll number which is taken as input. As soon as the match is found, the details of those particular students who have the required roll number will be updated accordingly in the database. The same iteration takes place until the matching roll number is found. For example, if the number 4 is selected from the numbers 1, 2, 3, 4 and 5, in which 1 represents updating the " first name of the student ", 2 represents " updating the last name of the student ", 3 represents " updating the roll number of the student ", 4 represents " updating the cgpa of the student " and 5 represents " updating the courses registered by the student ". So, as the input is given as 4, the cgpa of the student is updated, and the old cgpa will be replaced by the new cgpa. In this way, the working of the method " update() " is performed. ## 7. count():The method that helps in printing or acknowledging the user about the total number of students present within the database and also the number of students that can be taken as a new admission by considering the maximum number of students is the " count() " method. So, this method tells the user how many students are already existing and how many new students can be taken by considering the maximum number of students that can exist within the institute.
The method " count() " is used in order to calculate the total number of students and also prints the vacant places for the new students. In one of the previous methods, i.e., the method in which the new students are added, a variable " i " is declared in order to store the value of the students being added, and for every iteration, the value of " i " is incremented. At last, the final value of the variable " i " is fixed. That value is equal to the total number of students' details stored in the database. So, printing the value of " i " is performed in order to know the value of the total number of students. The value of " i " is subtracted from the maximum number of students that can be stored to know the number of vacancies for the students. These are the methods or functions that are responsible for the construction of the program " Student Record System in C ". The program is a combination of all the methods discussed above. Let us construct the program.
1. Add the details of the student 2. Find the details of the student by using roll number 3. Find the details of the student by using first name 4. Find the details of the student by using course id 5. Update the details of the student by using roll number 6. Delete the details of the student by using roll number 7. Find the total number of students 8. Exit Enter the choice number that you want to perform: 1 You can add the Student data now !! Enter the first name of the Student: Nikhitha Enter the last name of the Student: Manne Enter the roll number of the Student: 21 Enter the CGPA that the student achieved: 8.95 List of courses with their respective course ids: 1 2 3 4 5 1. Add the details of the student 2. Find the details of the student by using roll number 3. Find the details of the student by using first name 4. Find the details of the student by using course id 5. Update the details of the student by using roll number 6. Delete the details of the student by using roll number 7. Find the total number of students 8. Exit Enter the choice number that you want to perform: 2 You can find the Student data by entering a roll number now !! Enter the roll number of the Student: 21 The details of the Student with the roll given number are The First name of the student is Nikhitha The Last name of the student is Manne The CGPA of the student is 8.950000 The course ID is 1 The course ID is 2 The course ID is 3 The course ID is 4 The course ID is 5 1. Add the details of the student 2. Find the details of the student by using roll number 3. Find the details of the student by using first name 4. Find the details of the student by using course id 5. Update the details of the student by using roll number 6. Delete the details of the student by using roll number 7. Find the total number of students 8. Exit Enter the choice number that you want to perform: 3 You can find the Student data by entering the first name now !! Enter the first name of the Student: Nikhitha The details of the student are displayed below The First name of the student is Nikhitha The Last name of the student is Manne The Roll Number of the student is 21 The CGPA of the student is 8.950000 The course ID is 1 The course ID is 2 The course ID is 3 The course ID is 4 The course ID is 5 1. Add the details of the student 2. Find the details of the student by using roll number 3. Find the details of the student by using first name 4. Find the details of the student by using course id 5. Update the details of the student by using roll number 6. Delete the details of the student by using roll number 7. Find the total number of students 8. Exit Enter the choice number that you want to perform: 3 You can find the Student data by entering the first name now !! Enter the first name of the Student: Nikhitha The details of the student are displayed below The First name of the student is Nikhitha The Last name of the student is Manne The Roll Number of the student is 21 The CGPA of the student is 8.950000 The course ID is 1 The course ID is 2 The course ID is 3 The course ID is 4 The course ID is 5 1. Add the details of the student 2. Find the details of the student by using roll number 3. Find the details of the student by using first name 4. Find the details of the student by using course id 5. Update the details of the student by using roll number 6. Delete the details of the student by using roll number 7. Find the total number of students 8. Exit Enter the choice number that you want to perform: 4 You can find the Student data who have enrolled in the course. Enter the course ID of the desired course: 1 The details of the Students who have registered with the corresponding course id: The first name of the student is Nikhitha The last name of the student is Manne The Roll number of the student is 21 The CGPA of the student is 8.950000 1. Add the details of the student 2. Find the details of the student by using roll number 3. Find the details of the student by using first name 4. Find the details of the student by using course id 5. Update the details of the student by using roll number 6. Delete the details of the student by using roll number 7. Find the total number of students 8. Exit Enter the choice number that you want to perform: 5 Enter the roll number of the student that you want to update: 21 Enter the number for which details you want to update: 1. First name of the student 2. Last name of the student 3. Roll number of the student 4. CGPA of the student 5. Courses registered by the student 1 Enter the first name that you want to update : Nikki The Details of the Student are updated successfully !! 1. Add the details of the student 2. Find the details of the student by using roll number 3. Find the details of the student by using first name 4. Find the details of the student by using course id 5. Update the details of the student by using roll number 6. Delete the details of the student by using roll number 7. Find the total number of students 8. Exit Enter the choice number that you want to perform: 7 The total number of Students is: 1 The maximum number of students is 50 49 more students can be added 1. Add the details of the student 2. Find the details of the student by using roll number 3. Find the details of the student by using first name 4. Find the details of the student by using course id 5. Update the details of the student by using roll number 6. Delete the details of the student by using roll number 7. Find the total number of students 8. Exit Enter the choice number that you want to perform: 6 Enter the roll number of the student that you want to delete: 21 The details of the student bearing the given roll number are successfully removed 1. Add the details of the student 2. Find the details of the student by using roll number 3. Find the details of the student by using first name 4. Find the details of the student by using course id 5. Update the details of the student by using roll number 6. Delete the details of the student by using roll number 7. Find the total number of students 8. Exit Enter the choice number that you want to perform: 2 You can find the Student data by entering a roll number now !! Enter the roll number of the Student: 21 The course ID is 0 The course ID is 0 The course ID is 0 The course ID is 0 The course ID is 0 1. Add the details of the student 2. Find the details of the student by using roll number 3. Find the details of the student by using first name 4. Find the details of the student by using course id 5. Update the details of the student by using roll number 6. Delete the details of the student by using roll number 7. Find the total number of students 8. Exit Enter the choice number that you want to perform: 8 Exit successful!!
For the above program, all the possible inputs are given one by one after receiving the previous outputs. The options are given with their respective serial numbers so that one of those can be chosen by the user through the input. The options with their respective numbers are: - Add the details of the student
- Find the details of the student by using roll number
- Find the details of the student by using first name
- Find the details of the student by using course id
- Update the details of the student by using roll number
- Delete the details of the student by using roll number
- Find the total number of students
- Exit
So, the user will be asked to choose the desired option from the above-listed operations, and the operation that is selected will be performed. If the first option, i.e., " add the details of the student," is chosen, the details of a new student can be added. If the second option, i.e., " find the details of the student by using roll number ", is chosen, the details of an already existing student can be found using roll number. If the third option, i.e., " find the details of the student by using the first name", is chosen, the details of an already existing student can be found using the first name. Similarly, if the fourth option, i.e., " Find the details of the student by using course id ", is chosen, the details of an already existing student can be found using course id that is registered by the student. If the fifth option, i.e., " update the details of the student by using roll number ", is chosen, the details of an already existing student can be updated using the respective roll number. If the sixth option, i.e., " delete the details of the student by using roll number ", is chosen, the details of an already existing student can be deleted from the database using their respective roll number. If the seventh option, i.e., " find the total number of students ", is chosen, the total number of students will be displayed. If the eighth option, i.e., " Exit ", is chosen, you will exit from the terminal. In order to access and perform these operations, initially, the respective functions and methods are declared so that they can be accessed whenever required, accordingly. In this way, the database system that stores and secures the Student details can be created. Next TopicContact Management System in C |