Program:
#include<stdio.h>#define undefined 10000 /* take a value which is beyond the range of values in the program */
int main()
{
int n;
int i, j,count;
printf("n: ");
scanf("%d",&n);
int a[n];
printf("enter elements\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
count=1;
if(a[i]!=undefined)
for(j=i+1;j<n;j++)
{
if(a[i]==a[j])
{
count++;
a[j]=undefined;
}
}
if(a[i]!=undefined)
printf("(%d,%d); ",a[i],count);
}
return 0;
}
No comments:
Post a Comment