ispunct in c

The C ispunct function is used to check the given character is a Punctuation or not. The below is punctuation function in C Programming accept a character as the parameter and find whether that character is Punctuation or not.

ispunct(char)

ispunct in C Programming Example 1

The ispunct function finds whether the user given character is a Punctuation character or not.

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

int main()
{
    char ch = '!';
    
    if(ispunct(ch))
    {
        printf("\nYou have entered a Punctuation Character \n");
    }
    else
    {
        printf("\n %c is not a Punctuation Character", ch);
    }
    return 0;
}
You have entered a Punctuation Character 

C is punctuation Example 2

This program allows user to enter any character. And check whether the given character is a Punctuation or not using the C Programming ispunct function.

// ispunct in C Programming example
#include <stdio.h>
#include <ctype.h>

int main()
{
    char ch;
    
    printf("Please Enter Any Valid Character: ");
    scanf("%c", &ch);
    
    if(ispunct(ch))
    {
        printf("\nYou have entered a Punctuation Character \n");
    }
    else
    {
        printf("\n %c is not a Punctuation Character \n", ch);
    }
    return 0;
}
ispunct in C programming 2

Let me enter another character

Please Enter Any Valid Character: i

 i is not a Punctuation Character