Write a program to show student database in sorted order using data structure. |
Abstract
Student database using structure data type starts with defining a structure data type named as student. This structure data type should have all the member variable to hold the attributes of a student. Name, department, roll number, marks etc are primary members. Year, enrolment date/year, address etc can be added. Member variable should be with proper type like roll should be integer, marks is floating point and other like name field can be strings or array of characters. This program is implemented with array of structure. Linked list implementation can have list type with student as the node.
Now coming to the main program. Main must have an array of variables of type student to hold them in memory. Dynamic array of linked list can be used for runtime allocation. First we should take inputs from user about the details of each students and fill the array. We have used for loop and scanf() function. Now to display in sorted order we have done a sorting on this array. Sorting requires swapping of records of two students. So a function swap_sudent_record() is written. This takes the records of two students as reference and swaps the content. Now once this array is sorted, we have to display the record list. We have used a for loop and used printf() function to display the details.
Source Code
Output
Find More from our code collection
Armstrong number, binary number to a decimal number, bubble sort, decimal number to binary number, factorial of the given number
factors, fibonacci numbers, HCF and LCM, matrix, mergesort, salary of the employee.
palindrome, quadratic equation, star patterns, series etc. and much more...
Return to Example Source Code


Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions