Thursday 24 January 2013

finding character in string using array in c++


            #include <iostream>
            #include <conio>

              void main()

            {

            char arr[35],n;
            int i,loc;
                        cout<<"Enter characters\n";
            for(i=0;i<5;i++)
            {

            cin>>arr[i];}
                        cout<<"Enter any charter\t";cin>>n;
                        cout<<endl;
                  for(i=0;i<5;i++)

                  {
                    if(arr[i]==n)

                    {
                      loc=1;
                    }
                  }

                  if(loc==1)

                  cout<<"found character \t"<<n<<endl;

                         else
                         cout<<"Againg try\n";
           getch();
            }

0 comments:

Post a Comment