I have two array x and y. I want to find out duplicate value store in array y
I wrote program and I can find duplicate value
Code:
#include<stdio.h>
int main(void) {
int i = 0, j = 0;
int x[5] = { 1, 2, 4, 3, 5 };
int y[5] = { 10, 3, 13, 2, 17 };
int temp[5];
for ( i = 0; i < 5; i ++)
{
for ( j = 0; j < 5; j ++)
{
if ( x[i] == y[j])
{
printf("Number %d found \n", x[i] );
}
}
}
return 0;
}
program output
Code:
Number 2 found
Number 3 found
I am trying to solve following problem where duplicate number 3 is repeating two times
Code:
int x[5] = { 1, 2, 4, 3, 5 };
int y[5] = { 10, 3, 3, 2, 17 };
I don't understand how to make a logic that find how many time number repeats in array ?