P
Prem Mallappa
Hi everyone
this is the program given in answer book to K&R
====================================
#include <stdio.h>
int main()
{
printf (" signed char = %d", -(char) ((unsigned char) ~0 >> 1));
printf (" signed char = %d", (char) ((unsigned char) ~0 >> 1));
return 0;
}
==================================
This is to print the maximum value we can store in a signed char..
the output of this is
-127
127
but we can store -128 as the value in a signed char and also in <limits.h>
# define SCHAR_MIN (-128)
why is it given in that way in the most famous K&R answerbook
am i wrong or the program is wrong..
plz help me
regards
prem
this is the program given in answer book to K&R
====================================
#include <stdio.h>
int main()
{
printf (" signed char = %d", -(char) ((unsigned char) ~0 >> 1));
printf (" signed char = %d", (char) ((unsigned char) ~0 >> 1));
return 0;
}
==================================
This is to print the maximum value we can store in a signed char..
the output of this is
-127
127
but we can store -128 as the value in a signed char and also in <limits.h>
# define SCHAR_MIN (-128)
why is it given in that way in the most famous K&R answerbook
am i wrong or the program is wrong..
plz help me
regards
prem