ADVERTISEMENT
ADVERTISEMENT

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

Here, we are going to learn how to print all punctuation marks using the ispunct() function in C language?
Submitted by Nidhi, on August 25, 2021

Problem Solution:

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.

C Basic Programs »


ADVERTISEMENT




ADVERTISEMENT



Comments and Discussions!

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.