Q:

C program to print all printable characters using the isprint() function

0

C program to print all printable characters using the isprint() function

All Answers

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

Here, we will print all printable characters available in C using the isprint() library function.

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

Syntax:

int isprint( int ch);

The function accepts a parameter and returns non-zero integer, if not it returns 0.

Program:

The source code to print all printable characters using the isprint() 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 printable characters
// using isprint() function

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

int main()
{
    int cnt;
    printf("Printable characters are: \n");

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

    printf("\n");

    return 0;
}

Output:

Printable characters are: 
  ! " # $ % & ' ( ) * + , - . / 
0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ 
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 
[ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t 
u v w x y z { | } ~ 

Explanation:

Here, we printed all printable characters available in C language using the isprint() 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)

Similar questions


need a help?


find thousands of online teachers now