Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Python Programs
    • Java Programs
    • SQL FAQ’s

isalnum in C Programming

by suresh

The C isalnum function is one of the Standard Library Functions available in C language, which is useful to check the given character is either an alphabet or a numeric value. The syntax of the isalnum in C Programming language is

Below c isalnum function will accept the single character as the parameter, and check whether the given character is either a number or an alphabet.

isalnum(char)

isalnum in C Programming Example

The isalnum method (alphanumeric) used to find the given character is either an alphabet or numeric. This C program allows the user to enter any character. Next, it checks whether the character is between A to Z, or a to z, or a numeric value using the isalnum function.

//Example for isalnum in C Programming
#include <stdio.h>
#include <ctype.h>

int main()
{
    char ch;
    printf("Please Enter Either an Alphabet, or a Number: \n");
    scanf("%c", &ch);

    if(isalnum(ch))
    {
      printf("\n You have entered an Alphanumeric Character");         
    }
    else
    {
      printf("\n %c is not an Alphanumeric Character", ch);
      printf("\n I request you to enter Valid Number, or an Alphabet");	
    }
}

OUTPUT

isalnum in C Programming 1

Let me enter the Uppercase letter

isalnum in C Programming 2

Let me enter the Numeric value

isalnum in C Programming 3

ANALYSIS

In this isalnum in the c program, first, we declared a character variable called ch. The following C Programming statement will ask the user to enter any character. And then we are using the scanf to assign the user entered a character to ch variable

printf("Please Enter Either an Alphabet, or a Number: \n");
scanf("%c", &ch);

In this next line, we added the If Statement to check whether the character is between ‘A’ to ‘Z’, or ‘a’ to ‘z’, or a number using isalnum function. If the condition is True, the following statement will print

printf("\n You have entered an Alphanumeric Character");

If the above condition is FALSE, then the given character is not an Alphabet, or a number. So, this C program will print below statements

printf("\n %c is not an Alphanumeric Character", ch);
printf("\n I request you to enter Valid Number, or an Alphabet");

Above c isalnum code perfectly checking whether the given character is either an alphabet or a number. But what if, we enter the symbols

isalnum in C Programming 4

Let me try with the space character

isalnum in C Programming 5

Placed Under: C Programming

  • C Comments
  • C Escape Sequence
  • C Programming Operators
  • C Arithmetic Operators
  • C Assignment Operators
  • C Bitwise Operators
  • C Conditional Operator
  • C Increment & Decrement Optr
  • C Logical Operators
  • C Relational Operators
  • C Sizeof Operator
  • C If Statement
  • C IF ELSE Statement
  • C Else If Statement
  • C Nested If
  • C Break Statement
  • C Continue Statement
  • C Goto Statement
  • C Switch Case
  • C For Loop
  • C While Loop
  • C Do While Loop
  • C Arrays
  • C Two Dimensional Array
  • C Multi Dimensional Array
  • C String
  • C Structures
  • C Nested Structures
  • C Array of Structures
  • C Structures and Functions
  • C Union
  • C Structure & Union differences
  • C Pointers
  • C Pass Pointers to Functions
  • C GETS
  • C fgets Function
  • C fgetc
  • C fputs function
  • C fputc
  • C Functions
  • C Types of Functions
  • C Pass Array to Functions
  • Call By Value & Call By Reference
  • C Recursion
  • C Program Examples
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy