Wednesday, October 17, 2012

Using array find element in index of array taken input from user.

Posted by at 8:59 AM


Object  
      Using array find element in index of array taken input from user.

Source code

#include<iostream>
using namespace std;
void main()

{

       int enter;

       int find[12];

       cout << "Enter Numbers to save in array" << endl;

       for(int enter_loop = 0; enter_loop < 12; enter_loop ++)

       {

              cin >> find[enter_loop];

       }

       cout << "Enter a Number you want to see the address of number in array\n";

       cin >> enter;

       int loop;

       for(loop = 0; loop <= enter; loop++)

       {

                     if(find[loop] == enter)

                     {

                           cout << "The Address is: " << loop;          

                           break;

                     }

       }

}

Output

Check two same type array are equal or not

Posted by at 8:56 AM


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

Popular Posts

Labels

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