-->
Showing posts with label program to know repetition of elements stored in array.. Show all posts
Showing posts with label program to know repetition of elements stored in array.. Show all posts

program to know repetition of elements stored in array.

using turbo C++
-----------------------------------------------------------------------
//program to know repetition of elements stored in array.
#include<stdio.h>
#include<conio.h>
  void main()
  {
  clrscr();
  int arr[200],arr1[200],arra2_rep;    
  int size;     
  int i,j,k;      
 printf("enter size of elements \n");
  scanf("%d",&size); 
printf("enter array's elements\n");                 
  for(i=0;i<size;i++)
   {                            
     printf("enter elements for location=%d\n",i);
     scanf("%d",&arr[i]);      
   }
   printf("elements' sorting process started\n");
   for(i=0;i<size;i++)
   {
        arra2_rep=0;       for(j=i+1;j<size;j++)
        {
           if(arr[i]==arr[j])
             {
                 arr1[i]=ara2_rep++;
             }
       }
}
printf("repeated numbers are\n");
for(i=0;i<size;i++)
   {                            
     printf("number=%d and repeated times=%d\n",arr[i],arra1_rep[i]);      
   }
getch();
}

-------------------------------------------------------------------------------------------
in codeblocks
----------------------

//program to know repetition of elements stored in array.
#include<stdio.h>
  int main()
  {
  int arr[200],arr1[200],arra2_rep;    
  int size;     
  int i,j,k;      
 printf("enter size of elements \n");
  scanf("%d",&size); 
printf("enter array's elements\n");                 
  for(i=0;i<size;i++)
   {                            
     printf("enter elements for location=%d\n",i);
     scanf("%d",&arr[i]);      
   }
   printf("elements' sorting process started\n");
   for(i=0;i<size;i++)
   {

        arra2_rep=0;
       for(j=i+1;j<size;j++)
        {
           if(arr[i]==arr[j])
             {
                 arra2_rep++;
                 arr1[i]=arra2_rep;
             }
       }
}
printf("repeated numbers are\n");
for(i=0;i<size;i++)
   {                            
     printf("number=%d and repeated times=%d\n",arr[i],arr1[i]);      
   }
return 0;

}