isalpha() in C

Learn via video course
FREE
View all courses
C++ Course: Learn the Essentials
C++ Course: Learn the Essentials
by Prateek Narang
1000
5
Start Learning
C++ Course: Learn the Essentials
C++ Course: Learn the Essentials
by Prateek Narang
1000
5
Start Learning
Topics Covered

Overview

isalpha() is a function used to check whether the input character is an alphabet or not. It is present in the ctype header file in the C standard library.

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Syntax of isalpha() in C

The syntax of isalpha is:

Parameters of isalpha() in C

The isalpha() function takes the following parameter as an input.

  • c: a character or its ASCII value

Return Values of isalpha() in C

Return Type: int

The function returns different values depending on the input. They are as follows.

  • If the character is an alphabet(lowercase or uppercase), it returns a non-zero number.
  • If the character is not an alphabet, it returns zero.
Free Courses by top Scaler instructors
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course

Example of isalpha() in C

Output

What is isalpha() in C?

The isalpha() function in C is used to check whether a character is an alphabet or not. It is defined in the ctype header file in the C Standard Library.

It returns a non-zero number if it is an alphabet('a'-'z' and 'A'-'Z'). Else it returns zero for all other characters.

Note: To check whether the given character is an alphabet, the function converts the character into its ASCII value.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

More Examples

Let's see some more examples to understand how this function works.

Example 1: Program to use isalpha() function for lowercase alphabets

Output

Explanation In the above program, a lowercase alphabet(a) is passed to the function isalpha(). It returns a non-zero number(1024). Hence, the character passed is an alphabet.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Example 2: Program to use isalpha() function for uppercase alphabets

Output

Explanation In the above program, a uppercase alphabet(Q) is passed to the function isalpha. It returns a non-zero number(1024). Hence, the character passed is an alphabet.

Example 3: Program to use isalpha() function for numbers

Output

Explanation In the above program, a digit(9) is passed to the function isalpha. It returns zero. Hence, the character passed is not an alphabet.

Example 4: Program to use isalpha() function for special characters

Output

Explanation In the above program, a special character(*) is passed to the function isalpha. It returns zero. Hence, the character passed is not an alphabet.

Example 5: Program to use isalpha() function by passing ASCII values of characters.

Output

Explanation In this example, we pass the ASCII value of 'm'(ASCII value = 109) and '-'(ASCII value = 45) to the function. It returns the expected output.

Conclusion

  • The isalpha() function is defined in the ctype header file in the C standard library.
  • It is used to check whether a character is an alphabet or not.
  • It returns a non-zero if the character is an alphabet and zero otherwise.