0% found this document useful (0 votes)
46 views1 page

Printf Scanf Printf Scanf Printf

This code takes in an array of integers of a specified length from the user, then iterates through the array counting the number of occurrences of each unique integer. It prints out each unique integer along with the count of how many times it occurred in the original array.

Uploaded by

venitia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views1 page

Printf Scanf Printf Scanf Printf

This code takes in an array of integers of a specified length from the user, then iterates through the array counting the number of occurrences of each unique integer. It prints out each unique integer along with the count of how many times it occurred in the original array.

Uploaded by

venitia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

int main(){

int n, t, i, j, arr[30],len, halflen,flag=0,count=0;


printf("Enter number of elements to insert in an array:");
scanf("%d",&len);
printf("Enter elements to insert in an array:");
for(i=0;i<len;i++){
scanf("%d",&t);
arr[i]=t;
}printf("\n");
for(i=0;i<len;i++){
count=1;
for(j=i+1;j<=len-1;j++){
if(arr[i]==arr[j] && arr[i]!='\0'){
count++;
arr[j]='\0'; }}
if(arr[i]!='\0'){
printf("%d is %d times.\n",arr[i],count);
} }
getch();
return 0;}

You might also like