Ad Code

Responsive Advertisement

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

 

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

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

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].

ü 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.

ü 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 itscount in a string(Case Sensitive)

 

Post a Comment

0 Comments

Close Menu