the range of character constants is from -128 to 127....but in the following program....
main( )
{
char x;
for(x= -128; x<=127;x++)
{
printf("\n %d %c",x,x);
}
getch( );
}
the program gets into an indefinate loop while printing the ascii value & the character from -128 to 127.Altough the program does print the output but it is in the form of an indefinate loop.why does the program get into an indefinate loop?
in the above program if we alter the for statement as-
for(x= -128;x<=126;x++)
the above program prints the ascii value & the characters from -128 to 126 without getting into an indefinate loop.
why does the program enter an indefinate loop on specifing the limits as -128 to 127 while it doesnt in the case of -128 to 126?
Also we observed that on pressing ctrl+num lk/scroll lk we can escape an indefinate loop in progress.y does this happen....
thank u......
main( )
{
char x;
for(x= -128; x<=127;x++)
{
printf("\n %d %c",x,x);
}
getch( );
}
the program gets into an indefinate loop while printing the ascii value & the character from -128 to 127.Altough the program does print the output but it is in the form of an indefinate loop.why does the program get into an indefinate loop?
in the above program if we alter the for statement as-
for(x= -128;x<=126;x++)
the above program prints the ascii value & the characters from -128 to 126 without getting into an indefinate loop.
why does the program enter an indefinate loop on specifing the limits as -128 to 127 while it doesnt in the case of -128 to 126?
Also we observed that on pressing ctrl+num lk/scroll lk we can escape an indefinate loop in progress.y does this happen....
thank u......
Comment