Thursday, December 10, 2009

C++-->STORE NAMES OF N STUDENTS INTO AN ARRAY

Store names of n students into an array and then search for a particular name

#include

#include

#include

#include

void main()

{

int i,n,big;

int flag;

char name[100][25];

char t[25];

cout<<”Enter how many elements : “;

cin>>n;

for(i=0;i
gets(name[i]);



cout<<”Enter a name for search : “;

gets(t);

flag=0;

for(i=0;i
if(strcmp(name[i],t==0)

{

flag=1;

break;

}

if(flag= =1)

cout<<”The given name is found in the position “<
else

cout<<”The given name is not found”;

getch();

}

0 comments:

Post a Comment

Followers