Comments

Wednesday, October 17, 2012

Check two same type array are equal or not

Posted by at 8:56 AM Read our previous post


Object
1-      Check two same type array are equal or not.
Source code

{
       int first[5], second[5];
      
       int cont, newcont;

       cout << "Enter numbers in first Array" << endl;
      
       for(cont = 0; cont < 5; cont ++)
       {
              cin >> first[cont];
       }

       cout << "Enter numbers in second Array" << endl;

       for(int loop = 0; loop < 5; loop ++)
       {
              cin >> second[loop];
       }

       for(newcont = 0; newcont < 5; newcont ++)  //Checking both Array's one index at a time.
       {
              while(first[newcont] == second[newcont])
              {     
                           cout << "First array equla to second array" << endl;
                           return 0;
              }
              if(first[newcont] != second[newcont])
                     {
                           cout << "First Arrays is not equal to second second array" << endl;
                           return 0;
                     }
       }

}

Output

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Popular Posts

Labels

© Codepirate is powered by Blogger - Template designed by Stramaxon - Best SEO Template