Wednesday, 23 November 2016

Write a program that inputs ten integers in an array. It displays the number of occurrences of each numbers in the array.


       #include<iostream.h>
       #include<conio.h>
       void main()
       {
           int array[10],i,j,c,n;
           cout<<"Enter integers: ";
           for(i=0;i<10;i++)
           cin>>array[i];
           for(i=0; i<10; i++)
           {
             if (array[i]== -1)
             continue;
             n=array[i];
             c=1;
             for(j=i+1 ; j<10; j++)
              {
                if (array[j]==n)
                {
                    c++;
                   array[j]=-1;
                }
             }
            cout<<n<<" is stored "<<c<<" times in the array<<endl;
            }
         getche();

       }

No comments:

Post a Comment

If you have any doubt please let me know

Methods in JAVA Language

 In general, a way may be thanks to perform some task. Similarly, the tactic in Java may be a collection of instructions that performs a sel...