Wednesday, 6 August 2014

Find the output of the following program.


void main()
{
char ch;
for(ch=0;ch<=127;ch++)
printf(“%c   %d \n“, ch, ch);
}
Answer:
            Implementaion dependent
Explanation:

The char type may be signed or unsigned by default. If it is signed then ch++ is executed after ch reaches 127 and rotates back to -128. Thus ch is always smaller than 127.

No comments:

Post a Comment