Code:#include<stdio.h> #include<conio.h> #include<string.h> /*symbolic constant definition*/ #define L 31 #define SIZE 4 #define M 3 #define UCOST 1.50 /*structure definition*/ typedef struct { char name[L]; int numm[M]; float tcost; }astaff; /*function prototypes*/ void Input(astaff *prec); void Display(astaff *prec); void SearchByPartialSName(astaff rec[]); void SortBySName(astaff *prec); int main(void) { astaff rec[SIZE]; Input(&rec[0]);/*function call*/ Display(&rec[0]);/*function call*/ SearchByPartialSName(rec);/*function call*/ SortBySName(&rec[0]);/*function call*/ if(!getch())getch(); return 0; } /*function definition*/ void Input (astaff *prec) { int i,j, tmarker; char mcolor[M][6]= {"BLACK","BLUE","RED"}; for(i = 0; i <= SIZE; ++i, ++prec) { printf("***ACADEMIC STAFF # %d DATA ENTRY***\n", i+1); printf("NAME: "); scanf(" %[^\n]", prec->name); strupr(prec->name); printf("=>NUMBER OF WHITEBOARD MARKERS REQUESTED<=\n"); for(j = 0, tmarker = 0; j <= M; ++j) { printf("%s MARKERS:(0-5): ", mcolor[j]); scanf("%d", &prec->numm[j]); tmarker += prec->numm[j]; } prec->tcost[i] = tmarker * UCOST; printf("=>TOTAL COST = RM \n", &prec->tcost[i]); } return; } void Display (astaff *prec) { int i,j, marker; char mcolor[M][6]= {"BLACK", "BLUE", "RED"}; printf("%2s %-30s\n", "NO", "STAFFNAME"); for(j = 0; j < M; ++j) printf("%5s", mcolor[j]); printf("%15s\n", "TOTALCOST(RM)"); for(i = 0; i < SIZE; ++i) { printf("%2d %-30s", i+1, (prec+i)->name); for(j = 0; j < M; ++j) printf("%5d ", (prec+i)->numm[j]); printf("%15.2f\n", (prec+i)->tcost); } return ; } void SearchByPartialSName(astaff rec[]) { int i,j; char input[L]; printf("Enter a staff name to search: "); scanf(" %[^\n]", input); strupr(input); printf("%-30s %-6s %-6s %-6s %-6s %-16s\n", "STAFFNAME", "BLACK", "BLUE", "RED", "TOTALCOST"); for(i = 0; i < SIZE; ++i) if(strstr(rec[i].name, input) != NULL) { for(j = 0; j < M; ++j) printf("%-30s %5d %5d %3d %6c %5.1f\n", rec[i].name, rec[i].numm[j], rec[i].tcost); } if (i == SIZE) printf("Academic staff name not found!"); return; } void SortBySName(astaff *prec) { int i, pass; astaff temp; for(pass =1; pass < SIZE; ++pass) for(i=0; i < SIZE -1;++i) if(strcmp(prec[i].name,prec[i+1].name)>0) { temp = prec[i]; prec[i]= prec[i+1]; prec[i+1] = temp; } return ; }