# what's wrong in this code

+1 vote
I wanted to find if the integers are unique or repeated and if repeated then how many times. I want to display the repeated integer only one time to show its frequency.

#include <stdio.h>

int main()

{

int c=0,arr,i,j,m=0,k;

printf("Enter 4 integers :");

for(i=0; i<4;i++)

{

scanf("%d",&arr[i]);

}

for(i=0; i<4; i++)

{

c=0;

for(j=0; j<4; j++)

{

if(arr[i]==arr[j])

{

c++;

}

}

for(k=0; k<4; k++)

{

if(c>1)

arr[k]=arr[i];

}

if(c>1)

{

printf("\n%d was repeated %d times\n",arr[k],c);

m=2;

}

}

if(m==0)

{

printf(" All are Unique integers");

}

return 0;

}

+1 vote
answered Sep 3, 2018 by nk
#include <stdio.h>

int main ()
{
int c = 0, arr, i, j, m = 0, k;

printf ("Enter 4 integers :");

for (i = 0; i < 4; i++)

{

scanf ("%d", &arr[i]);

}

for (i = 0; i < 4; i++)

{

c = 0;

for (j = i+1; j < 4; j++)

{

if (arr[i] == arr[j])

c=c+1;

}

if (c >= 1)

{

printf ("\n%d was repeated %d times\n", arr[i], c);

m = 2;

}

}

if (m == 0)

{

printf (" All are Unique integers");

}

return 0;

}