isalpha() function in C17 Mar 2025 | 6 min read This section will discuss the isalpha() function of the C programming language. The islpha() function is a predefined library function of the ctype.h header file that takes an argument as the character type and validates for valid alphabets. If the given character is alphabets (a - z or A to Z), it returns a non-zero value; else, it returns 0. ![]() Note: While using the islpha() function, we must add the ctype.h header file in our program.For example, if the given character is from 'a' to 'z' and 'A' to 'Z', the isalpha() function returns a non-zero value. And if the given character is not the letters of the alphabets, it returns zeroes for other characters ( '@', '$', '&', etc.). Syntax of the isalpha functionFollowing is the syntax for the isalpha() function in C programming, as follows. Here, the isalpha() function takes ch as the character type argument to check the alphabetic letters. Parameters:Ch: It represents the character type variable to be checked. Return Value:The isalpha() function returns a non zero value when the 'ch' character is an alphabetic. Else, it shows the zero. Example 1: Program to check the alphabetic character using the islpha() function Let's consider an example to check whether the given character is alphabet using the islpha() function in the C programming. Output: 'a' is a valid alphabetic character. '&' is not a valid alphabetic character. Example 2: Program to validate the given character using the isalpha() function Let's consider a example to use the isalpha() function and check whether the various given character is alphabets or not in the C programming. Output: 'e' is an alphabetic character. 'Z' is an alphabetic character. '@' is not an alphabetic character. '5' is not an alphabetic character. Example 3: Program to get a character from user and check whether the character is valid character Let's consider an example to check valid characters using the isalpha function in C programming language. Output: Enter a valid character: g You entered a valid alphabet. In the above program, we take the 'g' character from the user and then use the isalpha() function to check whether the input character is an alphabet or not. If the character is an alphabet, it prints "You entered a valid character". 2nd execution: In the second execution, we input the '$' character and use the isalpha() function to check the character is an alphabet or not. Here '$' character is not an alphabet. So, it returns the "$ is not an alphabet. Please, enter a valid alphabet character ('a' to 'z' or 'A' to 'Z')". Example 4: Program to return a non zeroes values for alphabetic character using the isalpha() function Let's consider an example to validate the alphabetic character and returns a non zero values using the isalpha() function in the C programming language. Output: The result of valid uppercase alphabetic character is passed: 1 The result of valid lowercase alphabetic character is passed: 2 The result of non-alphabetic character is passed: 0 In the above program, we get different non-zero values when the alphabetic character is passed to the isalpha() function. But, when we pass the non-alphabetic character to the isalpha() function, it always returns 0. Example 5: Program to check all valid characters of the array using the isalpha() function Let's create an example to use the isalpha function to check the array character in C programming language. Output: '*' is NOT an Alphabetic character. '$' is NOT an Alphabetic character. '@' is NOT an Alphabetic character. '7' is NOT an Alphabetic character. 'Z' is an Alphabetic character. 'p' is an Alphabetic character. '!' is NOT an Alphabetic character. Next TopicBisection Method in C |
Matrix Multiplication
Matrix multiplication in C Matrix multiplication in C: We can add, subtract, multiply and divide 2 matrices. To do so, we are taking input from the user for row number, column number, first matrix elements and second matrix elements. Then we are performing multiplication on the...
2 min read
Difference between printf() and scanf() in C
Introduction: Printf() and Scanf() are inbuilt library functions in C language that perform formatted input and formatted output functions. These functions are defined and declared in stdio.h header file. The 'f' in printf and scanf stands for 'formatted'. So, both the functions printf() and scanf() use codes...
4 min read
What is the main in C
? In this topic, we will discuss the main in C programming language. A main is a predefined keyword or function in C. It is the first function of every C program that is responsible for starting the execution and termination of the program. It is a...
5 min read
Character stuffing program in C
Character stuffing is a technique used in computer programming to control data transmission between different systems or devices. It involves adding special characters or sequences of characters to the data being transmitted to mark the beginning and end of a data frame. This article will explore...
8 min read
Remove Duplicate Elements from an Array in C
This section will discuss the removing or deletion of the duplicate elements from an array in the C programming language. When the same number of elements occurs in sorted or unsorted array, then the elements of the array is called the duplicate elements. And we need...
7 min read
feof() function in C
In this article, we will discuss feof() function with its syntax, example, advantages, and disadvantages. When conducting file input operations in C, the feof() function is utilized to determine if the user has reached at the end of a file. It is frequently used with file-handling functions...
8 min read
Unsigned int in C
Unsigned int is a data type in the C programming language that stores non-negative integer values. It is similar to the "int" data type, but unlike "int", it does not allow for the storage of negative numbers. This article will explore C's unsigned int data type,...
12 min read
Relational Operator in C
Relational Operators in C In C programming, relational operators are mainly used to compare two expressions or sets of integers. Whether one operand is more than, equal to, or less than the other has no bearing on the validity of the connection. A Boolean response that...
11 min read
Binary search algorithm in C
A quick method for locating a particular element in a sorted array is a binary search. The initial task of this algorithm is to compare the target value to the array's middle element. The search is deemed successful if the target value is contained in the...
4 min read
C program to print the largest element in an array
9. In this program, we need to find out the largest element present in the array and display it. This can be accomplished by looping through the array from start to end by comparing max with all the elements of an array. If any of...
2 min read
We request you to subscribe our newsletter for upcoming updates.

We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India
