Search
 
SCRIPT & CODE EXAMPLE
 

C

Write a C program to print all unique elements in the array.

#include <stdio.h>
int main()
{
    int arr1[100], n,ctr=0;
    int i, j, k;
       printf("Input the number of elements to be stored in the array: ");
       scanf("%d",&n);
       printf("Input %d elements in the array :
",n);
       for(i=0;i<n;i++)
            {
	      printf("element - %d : ",i);
	      scanf("%d",&arr1[i]);
	    }
    printf("
The unique elements found in the array are: 
");
    for(i=0; i<n; i++)
    {
        ctr=0;
        for(j=0,k=n; j<k+1; j++)
        {
            if (i!=j)
            {
		       if(arr1[i]==arr1[j])
              {
                 ctr++;
               }
             }
        }
       if(ctr==0)
        {
          printf("%d ",arr1[i]);
        }
    }
       printf("

");
}
Comment

PREVIOUS NEXT
Code Example
C :: how to store a user input with spaces in c 
C :: rename c 
C :: plt hide axis ticks 
C :: buble sort c 
C :: allow unrelated histories 
C :: c string is int 
C :: sstf program in c 
C :: bash check if inside lxc 
C :: reading string with spaces in c 
C :: how to find all the missing dates and increment the series in r 
C :: send http request in C 
C :: binary search in c 
C :: Calculator_C 
C :: operators priority in c 
C :: c for schleife 
C :: find smallest number in array in c 
C :: bootstrap 5 image responsive 
C :: ROUNDING decimal number in C 
C :: xor swap 
C :: typedef in c 
C :: print short in c 
C :: initialize array c 
C :: malloc c include 
C :: create role in psql with password 
C :: arrays in c 
C :: concatenate two strings without standard library in C 
C :: getchar in c 
C :: c print characters 
C :: powershell list big files 
C :: c list 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =