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 it is Punctuation or not.
ispunct(char)
ispunct in C Programming Example
The ispunct function finds whether the user given character is a Punctuation or not.
#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", ch); } return 0; }
You have entered a Punctuation
C is punctuation Example 2
This program allows user to enter any letter. And check whether the given character is a Punctuation or not using the C Programming ispunct function.
#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; }

Let me enter another character
Please Enter Any Valid Character: i
i is not a Punctuation Character