Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

if i have an input as : 1 1 1 2 3 3 my output must be : 1 3 it worked for differ

ID: 3640199 • Letter: I

Question

if i have an input as: 1 1 1 2 3 3 my output must be: 1 3

it worked for different scenarios but I could not fiqure it out forthe above scenario..

I tried this   if((a[c]==a[d])&&(a[d]==a[d+1]))

but it just checks the second condition and print only 1 without printing 3 ,

 

Any help..

 

#include<stdio.h>
int main()
{
int n, a[10], b[10], count = 0, c, d;

printf("Enter number of elements in array ");
scanf("%d",&n);

printf("Enter %d integers ", n);
for(c=0;c<n;c++)
     scanf("%d",&a[c]);
printf("The duplicate elements are ");
    
for(c=0;c<n-1;c++)
      for(d=c+1;d<n;d++)
        if(a[c]==a[d])
           {

printf("%d ",a[c]);
       
           }
return 0;
}

Explanation / Answer

PS: Please rate the answer #include #include int main() { int a[10]={1,1,1,2,3,3}, n=6, c, d; int flag[10]; bool dup=false; printf("Given integers are: "); for(c=0;c