
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
isalpha() and isdigit() in C/C++
isalpha()
The function isalpha() is used to check that a character is an alphabet or not. This function is declared in “ctype.h” header file. It returns an integer value, if the argument is an alphabet otherwise, it returns zero.
Here is the syntax of isalpha() in C language,
int isalpha(int value);
Here,
value − This is a single argument of integer type.
Here is an example of isalpha() in C language −
Example
#include<stdio.h> #include<ctype.h> int main() { char val1 = 's'; char val2 = '8'; if(isalpha(val1)) printf("The character is an alphabet\n"); else printf("The character is not an alphabet\n"); if(isalpha(val2)) printf("The character is an alphabet\n"); else printf("The character is not an alphabet"); return 0; }
Output
Here is the output
The character is an alphabet The character is not an alphabet
isdigit()
The function isdigit() is used to check that character is a numeric character or not. This function is declared in “ctype.h” header file. It returns an integer value, if the argument is a digit otherwise, it returns zero.
Here is the syntax of isdigit() in C language,
int isdigit(int value);
Here,
value − This is a single argument of integer type.
Here is an example of isdigit() in C language,
Example
#include<stdio.h> #include<ctype.h> int main() { char val1 = 's'; char val2 = '8'; if(isdigit(val1)) printf("The character is a digit\n"); else printf("The character is not a digit\n"); if(isdigit(val2)) printf("The character is a digit\n"); else printf("The character is not a digit"); return 0; }
Output
Here is the output
The character is not a digit The character is a digit
- Related Articles
- IntlChar::isalpha() function in PHP
- Foreach in C++ and C#
- Comma in C and C++
- Loops in C and C++
- nextafter() and nexttoward() in C/C++
- Undefined Behaviour in C and C++
- rand() and srand() in C/C++
- INT_MAX and INT_MIN in C/C++ and Applications
- exit(), abort() and assert() in C/C++
- strdup() and strdndup() in C/C++\n
- Name Mangling and extern “C” in C++
- Difference between Structures in C and C++
- Alternating Vowels and Consonants in C/C++
- Variable Length Arrays in C and C++
- Pre & post increment operator behavior in C, C++, Java, and C#
