Ad Code

Responsive Advertisement

Non repeated or unique characters in String(Case Insensitive)

 

Printing Non-repeated or Unique Characters Using C program(Case Insensitive)

Unique Character from the string


Printing Unique characters from the string:

C Program:

Output 1:

Non-Repeated or Unique characters from the string output


Output 2:

Non-Repeated or Unique characters from the string output


From the above program,

ü a[i] is the character used for comparing.
ü a[j] is the character to be compared with a[i].
ü For every i increament, the count is initialized to 0, count gets increased whenever the character used for comparing gets repeated i.e a[i].
ü The above lines used to compare the characters in the string one by one, when the repeated character comes then its value is assigned to '0'(a[j]='0').
ü a[i]!='  ', this condition is used to not remove the repeated blank space from the string.
ü tolower() is used to convert the uppercase letters to lowercase letters for comparing. Thus it provides the case insensitive operation for removing the repeated characters.

ü When the count is greater than 0 it indicates that a[i] occurs more than 1 time, then it  assigns the value '0' to a[i].
ü So, the repeated characters are assigned to the value '0'.

ü The above lines used to print the final string without '0' value assigned to the repeated character.
ü So this avoid printing dandelions as 0a00elio0s.

Post a Comment

0 Comments

Close Menu