include #include #define SIZE 6 struct Student{ char name[50]; int id; float mark; }; int Search1(char input[], struct Student data[]); int Search2(int input, struct Student data[]); int main() { char search_name[30]; int search_id; int result1, result2; struct Student list[SIZE] = { {"Amylia", 544199, 75.4}, {"Cheong", 143566, 92.3}, {"Harry", 109774, 65.5}, {"Krishnan", 334514, 86.7}, {"Melissa", 257890, 55.4}, {"Timothy",144656, 77.8}}; printf("Enter Student Name: "); gets(search_name); result1 = Search1(search_name, list); //Answer for part (a)(ii) – Display the matching index of result1 printf("Enter Student ID: "); scanf("%d",&search_id); result2 = Search2(search_id,list); //Answer for part (a)(iii)- Display the matching index of result2 return 0; } //Answer for part (a)(i) – function definition for Search1 //Answer for part (a)(iii) – function definition for Search2

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question


#include <stdio.h>
#include <string.h>
#define SIZE 6
struct Student{
char name[50];
int id;
float mark;
};
int Search1(char input[], struct Student data[]);
int Search2(int input, struct Student data[]);
int main() {
char search_name[30];
int search_id;
int result1, result2;
struct Student list[SIZE] = {
{"Amylia", 544199, 75.4},
{"Cheong", 143566, 92.3},
{"Harry", 109774, 65.5},
{"Krishnan", 334514, 86.7},
{"Melissa", 257890, 55.4},
{"Timothy",144656, 77.8}};
printf("Enter Student Name: ");
gets(search_name);
result1 = Search1(search_name, list);
//Answer for part (a)(ii) – Display the matching index of result1
printf("Enter Student ID: ");
scanf("%d",&search_id);
result2 = Search2(search_id,list);
//Answer for part (a)(iii)- Display the matching index of result2
return 0;
}
//Answer for part (a)(i) – function definition for Search1
//Answer for part (a)(iii) – function definition for Search2

Program Listing in Q4(a) intends to implement 'binary' and 'sequential' searching functions for an
array of student records. Study the code snippet carefully and answer the following questions.
(i) Write the function definition for Search1 that implements a binary search
to search for a particular student's name in an array of records. The function
takes in the search_name and array of Student structures. If a match
is found, the function returns the index of the matching element, otherwise
it returns -1.
(ii) Write a suitable C code to display the details (i.e. student name, student ID
and mark) of the matching element of search_name (from result1).
(iii) Write the function definition for sSearch2 that implements a sequential
search to search for a particular student's ID number in an array of records.
The function takes in the search_id and array of Student structures.
If a match is found, the function retums the index of the matching element,
otherwise it returns -1.
Transcribed Image Text:Program Listing in Q4(a) intends to implement 'binary' and 'sequential' searching functions for an array of student records. Study the code snippet carefully and answer the following questions. (i) Write the function definition for Search1 that implements a binary search to search for a particular student's name in an array of records. The function takes in the search_name and array of Student structures. If a match is found, the function returns the index of the matching element, otherwise it returns -1. (ii) Write a suitable C code to display the details (i.e. student name, student ID and mark) of the matching element of search_name (from result1). (iii) Write the function definition for sSearch2 that implements a sequential search to search for a particular student's ID number in an array of records. The function takes in the search_id and array of Student structures. If a match is found, the function retums the index of the matching element, otherwise it returns -1.
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY