Pattern Codes, ABCDE Code, Arduino Code

Saturday, 14 January 2017

Repeated Number in Array

Repeated number in array:

Output:

 Enter the number in array 8
5
6
4
5
1
2
 8 5 6 4 5 1 2

 Repeated number is :: 5

Code:

#include<stdio.h>

int main()
{
int arr[20];
int arr2[20];
int n,count=0,i,j;
printf("\n Enter the number in array ");
for(i=0;i<=6;i++)
{ //input array elements
scanf("%d",&arr[i]);
}
for(i=0;i<=6;i++)
{ //print array elements
printf(" %d",arr[i]);
}
printf("\n Repeated number is :: ");
for(i=0;i<=6;i++)
{ //loop for checking the repeated elements
for(j=i+1;j<=6;j++)
{
if(arr[i] == arr[j])
{
printf("%d ",arr[i]);
}
}
}
}

No comments :

Post a Comment

Rolls Royce

Rolls Royce
Amazing Cars

About Me