Q:

C program to print all punctuation marks using the ispunct() function

0

C program to print all punctuation marks using the ispunct() function

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Here, we will print all punctuation marks available in C language using the ispunct() function.

The ispunct() function checks whether a character is a punctuation character or not. This function is defined in ctype.h header file.

Syntax:

int ispunct(int ch);

The function accepts a character and returns nonzero if the character is a punctuation character; zero, otherwise.

Program:

The source code to print all punctuation marks using the ispunct() function is given below. The given program is compiled and executed using GCC compile on UBUNTU 18.04 OS successfully.

// C program to print all punctuation marks
// using ispunct() function

#include <stdio.h>
#include <ctype.h>

int main()
{
    int cnt;
    printf("Punctuation marks are: \n");

    for (cnt = 0; cnt <= 127; cnt++)
        if (ispunct(cnt) != 0)
            printf("%c ", cnt);

    printf("\n");

    return 0;
}

Output:

Punctuation marks are: 
! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~

Explanation:

Here, we printed all punctuation marks available in C language using the ispunct() library function on the console screen.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C programming Basic Input, Output, if else, Ternary Operator based Programs

Similar questions


need a help?


find thousands of online teachers now
C program to print all printable characters using ... >>
<< C program to print all punctuation marks without u...