Friday, 26 July 2013

Chapter 3 solutions Problem [B][d]

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-
it's a good question. see it's solution.

#include<stdio.h>
int main()
{
int ch=1;
while(ch<=255)
{
printf("AscII value %d =%c\n",ch,ch);
ch++;
}
return 0;
/* many people must have been wondering, why i have chosen ch is int, in case you haven't noticed. you would read about it in further chapters of the book, but just for knowledge, char values varies from -128 to 127 ,if it exceeds from 127 ,then  compiler chooses value from negative side. this process continues and causes an indefinite loop, which certainly you don't want */ 

1 comment: