What are character analysis function, explain with C program?



Character analysis and conversion functions

The predefined functions in “ctype.h” library is for analyzing the character input and converting them.

Analysis functions

S.No Function Description
1 isalpha() An alphabet or not
2 isdigit() A digit or not
3 isspace() A space, a new line or tab
4 ispunct() A special symbol or not
5 slower() A lower case letter of alphabet
6 isupper() An upper case letter of alphabet
7 isalphanumeric() An alphabet/digit or not

Converting functions

Function Description
tolower() Converts an upper case alphabet to lower case
toupper() Converts a lower case alphabet to upper case

Example

Let us see a program to demonstrate character analysis and conversion functions −

 Live Demo

#include<stdio.h> #include<ctype.h> void main(){    //Initializing compile time character variable// char variable = 'A';    //Reading User I/P//    //printf("Enter the character : ");    //scanf("%c",variable);    //Using character analysis function & printing O/p//    if (isalpha(variable)){       printf("The character entered is :%c, an alphabet",variable);    } else {       printf("The character entered is not an alphabet");    } }

Output

The character entered is :A, an alphabet
Updated on: 2021-03-09T09:17:07+05:30

263 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements