Printing Characters with its count in a String Using C program
Printing Characters with its count in a string(Case Sensitive):
C Program:
Output 1:
Output 2:
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 1, 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') and count is increased by 1.
ü a[i]!='
', this condition is used to not remove the repeated blank space from the
string.
ü The above lines used to print the count of the repeated characters in the given string.
Note: printing characters with its count in a string(Case Insensitive)
0 Comments