Skip to main content

Today, let’s learn how to print ASCII values using the while loop in C. I am referring to an awesome book called “Let us C” by “Yashwant Kanetkar” and I will post solutions to the questions asked in exercises. This is the fourth program of the third chapter: The Loop control structure. Please come back for more programs.  If you are unsure about any part and more information, put it down in the comments section below or look it up on Google if you want a quick response. We try to answer all the queries as soon as possible.

Question:

Write a program to print all the ASCII values and their equivalent characters using a while loop. The ASCII values vary from 0 to 255.

Solution to Print ASCII Values Using While Loop in C Program:

This is a simple program where you need to print all the ASCII characters using the while loop. First, we initialise a number variable with a value of 0. The next step is to create a while loop which counts the number variable through 0 – 255.  Then we print the character variables using the printf() function.

Download the source code:

Download Program

Program to Print ASCII Values Using While Loop in C Program:

//C Program to Print ASCII values using while loop in C by ReadMeNow
#include <stdio.h> 
#include <conio.h> 
int main() 
{
int number=0;
clrscr();
while(number<=255)
{
printf("character = %c",number);
number++;
}
return(0);
}

Output

Å É æ Æ ô ö ò û ù ÿ Ö Ü ¢ £ ¥ ₧ ƒ á í ó ú ñ Ñ ª º ¿ ⌐ ¬ ½ ¼ ¡ « » ░ ▒ ▓ │ ┤ ╡ ╢
╖ ╕ ╣ ║ ╗ ╝ ╜ ╛ ┐ └ ┴ ┬ ├ ─ ┼ ╞ ╟ ╚ ╔ ╩ ╦ ╠ ═ ╬ ╧ ╨ ╤ ╥ ╙ ╘ ╒ ╓ ╫ ╪ ┘ ┌ █ ▄ ▌ ▐
▀ α ß Γ π Σ σ µ τ Φ Θ Ω δ ∞ φ ε ∩ ≡ ± ≥ ≤ ⌠ ⌡ ÷ ≈ ° ∙ · √ ⁿ ² ■   ☺ ☻ ♥ ♦ ♣ ♠
♫ ☼ ► ◄ ↕ ‼ ¶ § ▬ ↨ ↑ ↓ ← ∟ ↔ ▲ ▼ ! ” # $ % &amp; ‘ ( ) * + , – . / 0 1 2 3 4 5 6
7 8 9 : ; &lt; = &gt; ? @ 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 { | } ~ ⌂ Ç ü é â ä à å
ç ê ë è ï î ì Ä

Download the source code:

Download Program

Read Also:

Introduction to C Programming

Multiplying two numbers in C

How to Calculate Simple Interest in C Programming

Calculate gross salary in C

Harsh Shah

Harsh Shah

A highly motivated individual with a hunger to learn and share as much as I can about everything. Masters in Interaction Design with a Bachelors in Computer Science. I have worked with clients across the globe on various design and tech projects. I believe in giving back and that's how ReadMeNow was founded.

Leave a Reply