Write a c program to accept the n names from the user stores these names into 2-d array accept the name from user and search whether the name is present in an array or not

#include<stdio.h>
#include<conio.h>
#include<string.h>
#define ROW 20
#define COL 20
main()
{
char data[ROW][COL],serch[ROW];
int flag=0,i,j,n;
clrscr();
printf("\n enter the limit");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
printf("\n enter the data=");
gets(data[i]);
}
printf("\n enter the string for serch ");
gets(serch);
for(i=0;i<n;i++)
{
if(strcmp(data[i],serch)==0)
{
flag=1;
break;
}
}
if(flag==1)
printf("\n enter is found");
else
printf("\n name is not found");
getch();
}

Comments