Read a number from the keyboard, and show its ASCII Equivalent symbol | Number to ASCII program in C

Spread the love
Number-to-ASCII-Conversion-program

Program Introduction:

Write a C Program to Convert a Number to ASCII Symbol. The Program should take input a number from the user and then display the ASCII equivalent of it.

Here are couple of expected inputs and outputs.

Example 1:

Input:

Output:

The ASCII equivalent of 65 is Upper case ‘A’.

Example 2:

Input:

Output:

Example 3:

Input:

Output:

Example 4:

Input:

Output:

Number to ASCII Conversion Program logic:

We are going to take Numbers from 0 to 255 only. If user enters any other number, Then display the error message.

But only 127 ASCII characters are printable characters. To be exact the printable ASCII Characters from number 32 which is space to number 126 which is ESC. So our output might give undefined values after 127 Number.

The basic idea is to pass the integer value to  printf function and use the character format specifier ( %c). So the printf function will cast the integer to ASCII character. and prints the ASCII Symbol output to the console.

📢 ASCII symbols for the numbers between 128 to 255 are non-printable, So we might get undefined output for numbers after 127.

Program: Number to ASCII Conversion:

Number to ASCII Program Output:

We are using the GCC compiler in Linux OS to compiler the program.

Related Programs:

Learn more about ASCII :

Venkat

Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

Leave a Reply