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
#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
Step by step
Solved in 3 steps with 2 images