practical part 3
practical part 3
practical part 3
Assignment No.1
Problem Statement:- Consider a student database of SEIT class (at least 15 records). Database
contains different fields of every student like Roll No, Name and SGPA.(array of structure)
c) Arrange list of students to find out first ten toppers from a class. (Use Quick sort)
*/
//CODE:
#include <iostream>
#include <cstring>
struct student {
int roll_no;
char name[30];
float SGPA;
};
// ACCEPT FUNCTION
}
}
// DISPLAY FUNCTION
cout << "\n " << list[i].roll_no << " \t " << list[i].name << "\t " << list[i].SGPA;
int pivot, i, j;
pivot = first;
i = first;
j = last;
while (i < j) {
i++;
j--;
if (i < j) {
swap(list[i], list[j]);
}
swap(list[pivot], list[j]);
quick_sort(list, j + 1, last);
int main() {
int ch, i;
accept(data);
do {
switch (ch) {
case 1:
display(data);
break;
case 2:
break;
default:
return 0;
Output =
Enter Roll-Number, Name, SGPA:102 Aditya 7.8
1) Quick Sort
2) Exit
105 Tejas 8
1) Quick Sort
2) Exit