C Library ctype.h

  • ctype means characters type in c library. Here will discuss about ctype.h
  • Use of this functions is know which type of characters isdigit(), isalpha()isupper(), islower()  , spunct().

C Program – Uppercase, Lowercase Alphabetic Characters using Switch Statement

#include <stdio.h>

int main() {
    char ch;
    printf("Pls Enter an Alphabetical character\n");
    scanf("%c", &ch);
    switch (ch) {
        case 'A' ... 'Z':
            printf("%c is in Uppercase\n", ch);
            break;
        case 'a' ... 'z':
            printf("%c is in Lowercase\n", ch);
            break;
        default:
            printf("Pls Enter an Alphabet\n");
    }
    return 0;
}

isdigit()

  • Used to check is character is numeric digit or not.
  • Syntax : int isdigit(c); here c is a variable or constant.
  • Returns : True – Non-zero, false – Zero.

isalpha() in ctype.h

  • Used to check is character is alphabet or not.
  • Syntax : int isalpha(c); here c is a variable or constant.
  • Returns : True – Non-zero, false – Zero.

isupper()

  • Used to check is character is upper or not.
  • Syntax : int isupper(c); here c is a variable or constant.
  • Returns : True – Non-zero, false – Zero.

islower() in ctype.h

  • Used to check is character is lower or not.
  • Syntax : int lower(c); here c is a variable or constant.
  • Returns : True – Non-zero, false – Zero.

ispunct()

  • Used to check is character is punctuation or not.
  • Syntax : int ispunct(c); here c is a variable or constant.
  • Returns : True – Non-zero, false – Zero.

Previous & Next

Please turn AdBlock off, and continue learning

Notice for AdBlock users

Please turn AdBlock off