Given a string, write a program to count the occurrence of Lowercase characters, Uppercase characters, Special characters, and Numeric values.
Input : #GeeKs01fOr@gEEks07 Output : Upper case letters : 5 Lower case letters : 8 Numbers : 4 Special Characters : 2 Input : *GeEkS4GeEkS* Output : Upper case letters : 6 Lower case letters : 4 Numbers : 1 Special Characters : 2
- Scan string str from 0 to length-1.
- check one character at a time on the basis of ASCII values
- if(str[i] >= 65 and str[i] <=90), then it is uppercase letter,
- if(str[i] >= 97 and str[i] <=122), then it is lowercase letter,
- if(str[i] >= 48 and str[i] <=57), then it is number,
- else it is a special character
- Print all the counters.
Upper case letters: 5 Lower case letters : 8 Number : 4 Special characters : 2
This article is contributed by Rishabh Jain. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Check if lowercase and uppercase characters are in same order
- Maximum distinct lowercase alphabets between two uppercase
- Program to display all alphabets from A to Z in uppercase and lowercase both
- Convert all lowercase characters to uppercase whose ASCII value is co-prime with k
- Check input character is alphabet, digit or special character
- Split numeric, alphabetic and special symbols from a String
- For each lowercase English alphabet find the count of strings having these alphabets
- Count substrings that starts with character X and ends with character Y
- Count special palindromes in a String
- Count the number of Special Strings of a given length N
- Minimize ASCII values sum after removing all occurrences of one character
- Count number of substrings with numeric value greater than X
- Program to count vowels, consonant, digits and special characters in string.
- Count all substrings having character K
- Count of sub-strings that contain character X at least once
- Count of sub-strings that do not consist of the given character
- Count of substrings which contains a given character K times
- Number of substrings with count of each character as k
- Program to count occurrence of a given character in a string
- Count occurrences of a character in a repeated string