u

Wednesday 6 June 2012

C++ Program to assign names of any four subjects and check if it is present using double dimensional arrays

C++ Program to assign names of any four subjects and check if it is present using double dimensional arrays



#include <iostream.h>
#include <string.h>
#include <conio.h>
//Global varibales
char str[][20]={"english","physics","chemistry","history"};
void find(char *);//find function
void main()


    {
    clrscr();
    char st[20];
    cout<<"Enter the name of any subject to find here;"<<endl;
    cin>>st;
    find(st);
}
void find(char *s)


    {
    int i,flag=0;
    for(i=0;i<3;i++)


    {
    if(strcmp(s,str[i])==0)


        {
        flag=1;
        cout<<"FOUND";
        getch();
    }
    }
    if(flag==0)
    {cout<<"NOTFOUND";
    cout<<"\ You are the Trespasser";}
    getch();
} 

0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More