Assume that following initialization is given in your structure allStudent[5] and data is sorted based on name field, struct studInfo { int stNr; char name[10] ; int grade; }; int main() // already sorted base on name field { struct studInfo allStudent[5]={ 97790, “ADEM” , 77, 963582, “AFGAR” , 85, 957434 ,”AHMED”, 100, 921229 ,”BAKI” , 65, 971280 ,”ZEKI” , 88}; int n=5;/* Total number of students*/ char givenName[10]; gets(givenName); k=binarySearch(………..); … …. sortBubble(……); .. .. .. return 0; } A) Write a C function named as binarySearch() and search a given student(get a name information from the monitor) in the given array allStudent[] , apply Binary Search , and list student information(stNr , name , grade).If student in not found give an error message in the main() program that “Student is not found”. B)Write a C function named as sortBubble() that will sort the student information by Student Number(stNr) applying by Bubble Sort method, and after sort operation list sorted student information in the main program.
Assume that following initialization is given in your structure allStudent[5] and data is sorted based on name field,
struct studInfo
{ int stNr;
char name[10] ;
int grade;
};
int main() // already sorted base on name field
{
struct studInfo allStudent[5]={ 97790, “ADEM” , 77,
963582, “AFGAR” , 85,
957434 ,”AHMED”, 100,
921229 ,”BAKI” , 65,
971280 ,”ZEKI” , 88};
int n=5;/* Total number of students*/
char givenName[10];
gets(givenName);
k=binarySearch(………..);
…
….
sortBubble(……);
..
..
..
return 0;
}
- A) Write a C function named as binarySearch() and search a given student(get a name information from the monitor) in the given array allStudent[] , apply Binary Search , and list student information(stNr , name , grade).If student in not found give an error message in the main() program that “Student is not found”.
B)Write a C function named as sortBubble() that will sort the student information by Student Number(stNr) applying by Bubble Sort method, and after sort operation list sorted student information in the main program.
Step by step
Solved in 3 steps with 6 images