by Dinesh Thakur Category: Control Structures

The program segment given below accepts an integer number in variable digit of type int from the keyboard and if it is a single digit number (0-9), it displays the word corresponding to it;


otherwise, it displays the message Not a digit. The switch statement has a case block for each digit (0-9) and a default block to handle all other numbers. Note that the code for each case has been written on a single line to save space.

#include <stdio.h>

void main()


     int digit;


     printf("Enter a digit (0-9): ");

     scanf ("%d", &digit);

     switch (digit)


          case 0: printf("Zero"); break;

          case 1: printf("One"); break;

          case 2: printf("Two"); break;

          case 3: printf("Three"); break;

          case 4: printf("Four"); break;

          case 5: printf("Five"); break;

          case 6: printf("Six"); break;

          case 7: printf("Seven"); break;

          case 8: printf("Eight"); break;

          case 9: printf("Nine"); break;

          default:printf("Not a digit"); break;





    C Program for print a given digit as a word

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Search Content

Popular Article