Ad Code

Responsive Advertisement

Printing Characters with its count in a string(Case Sensitive)

 

Printing Characters with its count in a String Using C program(Case Sensitive)

Characters With its count in a string


Printing Characters with its count in a string(Case Sensitive):

C Program:

Output 1:

Characters with its count output

Output 2:

Characters with its count 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 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.


ü The above line used to print the count of the non repeated character(Whose count will be 1) in the given string.

Note: printing characters with its count in a string(Case Insensitive)

Post a Comment

0 Comments

Close Menu