Duplicate Numbers 1. Write a program to display the duplicate values in an array
ID: 3628511 • Letter: D
Question
Duplicate Numbers1. Write a program to display the duplicate values in an array.
Formulas Needed: None
Final submission along with Code
Documentation & Naming Style Sheet
1. Opening Documentation: the header block should include the following:
* Program name/syntax
* Description of what the program does
* Summary of the problem's specifications and assumptions
* License info (optional)
* References to sources of additional information used
* Parameters
* Class/Program Invariant (ensure these conditions are true)
* Algorithm(s) used (including any special notes)
* Output (any print statements, files created, etc.)
* Return values (does it return any parameters?)
* Name of the authors (plus contact info)
* Creation & modification dates
Explanation / Answer
please rate - thanks
#include <stdio.h>
#include <conio.h>
int main()
{int a[]={1,2,3,4,5,6,7,8,3,4,2,9};
int used[12]={0};
int n=12,i,j,k;
printf("The array ");
for(i=0;i<n;i++)
printf("%d ",a[i]);
printf(" The duplicate values ");
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
if(a[i]==a[j])
if(used[i]==0)
{printf("%d ",a[i]);
used[i]=1;
used[j]=1;
for(k=j+1;k<n;k++)
if(a[i]==a[k])
used[k]=1;
}
getch();
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.