Home »
C solved programs »
C basic programs
C program to print all printable characters using the isprint() function
Here, we are going to learn how to print all printable characters using the isprint() function in C language?
Submitted by Nidhi, on August 25, 2021
Problem statement
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.
C Basic Programs »