isalpha(c) is a function in C which can be used to check if passed character is an alphabet or not. It returns a non-zero value if it’s an alphabet else it returns 0. For example, it returns non-zero values for ‘a’ to ‘z’ and ‘A’ to ‘Z’ and zero for other characters.
Similarly, isdigit(c) is a function in C which can be used to check if passed character is a digit or not. It returns a non-zero value if it’s a digit else it returns 0. For example, it returns non-zero value for ‘0’ to ‘9’ and zero for others.
Example Problem : Given a string str, find the number of alphabetic letters and number of decimal digits in that string.
Input: 12abc12 Output: Alphabetic_letters = 3, Decimal_digits = 4 Input: 123 GeeksForGeeks is Number 1 Output: Alphabetic_letters = 21, Decimal_digits = 4
Explanation And Approach:
Alphabetic_letters = 3, Decimal_digits = 4
This article is contributed by Mazhar Imam Khan. 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.
- Check input character is alphabet, digit or special character
- strspn() function in C
- Core Dump (Segmentation fault) in C/C++
- strcpy in C/C++
- Conversion of whole String to uppercase or lowercase using STL in C++
- Operators in C / C++
- How to pass an array by value in C ?
- Pointers in C and C++ | Set 1 (Introduction, Arithmetic and Array)
- Nested printf (printf inside printf) in C
- std::string class in C++
- Converting Strings to Numbers in C/C++
- Different methods to reverse a string in C/C++
- Vector in C++ STL
- Functions in C/C++
- Data type of case labels of switch statement in C++?