SYB.B.A.(C.A.) Sem III : Data Structure Slip 17 Que - 1 B
SAVITIBAI PHULE UNIVERSITY OF PUNE S. Y. B.B.A. (C.A.) Semester III Practical Examination Lab Course: (CA-306) Computer Laboratory Based on 302, 304 and 305 Data Structure, Angular JS/ PHP, Big Data / Block Chain /* Q.1 B) Write a 'C' program to accept the names of cities and store them in array. Accept the city name from user and use linear search algorithm to check whether the city is present in array or not */ #include<stdio.h> #include<stdlib.h> #define MAX 30 void CreateArray(char A[][MAX], int n) { int i = 0; fflush(stdin); printf("\n\nEnter the City names to store into the Array: \n"); for ( i = 0; i < n; i++) fgets(A[i], sizeof(A[i]), stdin); } void DisplayArray(char A[MAX][MAX], int n) { int i = 0; printf("\n\nThe City names are: \n"); for ( i = 0; i < n; i++) printf("%s", A[i]); } void LinearSearch(char A[][MAX], int n, char key[]) { int i = 0, flag = 0;