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.NoFunctionDescription
1isalpha()An alphabet or not
2isdigit()A digit or not
3isspace()A space, a new line or tab
4ispunct()A special symbol or not
5slower()A lower case letter of alphabet
6isupper()An upper case letter of alphabet
7isalphanumeric()An alphabet/digit or not

Converting functions

FunctionDescription
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: 09-Mar-2021

145 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements