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 email@example.com. 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.
- Program to display all alphabets from A to Z in uppercase and lowercase both
- Check if lowercase and uppercase characters are in same order
- Maximum distinct lowercase alphabets between two uppercase
- 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
- Count substrings that starts with character X and ends with character Y
- Count special palindromes in a String
- Count number of substrings with numeric value greater than X
- Minimize ASCII values sum after removing all occurrences of one character
- Program to count vowels, consonant, digits and special characters in string.
- Count of sub-strings that contain character X at least once
- Count all substrings having character K
- Count characters in a string whose ASCII values are prime
- Count the number of words having sum of ASCII values less than and greater than k