98.1k views
3 votes
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.

User MMKarami
by
5.0k points

1 Answer

4 votes

Answer:

I am going to write a C program. The program is in the explanation. You use a simple while loop controled by a counter(don't forget to initialize nor increment the counter). Inside the while loop, you printf the ASCII value as a %d and the equivalent character as a %c.

Step-by-step explanation:

#include <stdio.h>

int main(){

int i = 0;

/*While loop*/

while(i < 256){

printf("ASCII value: %d\\", i);

printf("ASCII character: %c\\", (char)i);

i++;

}

return 0;

}

User Amin Saffar
by
5.0k points