Q25 Write a C program to find duplicate integer in an array.

#include<stdio.h>

int main()

{

        int i, j, temp, arr[10];

        printf(“Enter the number with some repeated number\n”);

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

        {

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

        }

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

        {

                temp = arr[i];

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

                {

                        if(i != j)

                        {

                        if(temp == arr[j])

                        {

                                printf(” Number %d is duplicate in array \n”,arr[j]);

                        }

                        }

                }

        }

        return 0;

}

Output:

$ ./a.exe

Enter the number with some repeated number

1

1

4

4

2

3

5

6

7

8

 Number 1 is duplicate in array

 Number 1 is duplicate in array

 Number 4 is duplicate in array

 Number 4 is duplicate in array

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.