Q. What will be the output of the following C code?
Code:
#include <stdio.h>
int main()
{
unsigned char c=290;
printf("%d",c);
return 0;
}
β
Correct Answer: (C)
56
Explanation: 290 is beyond the range of unsigned char. Its corresponding value printed is: (290 % (UCHAR_MAX +1) where UCHAR_MAX represents highest (maximum) value of unsigned char type of variable. The value of UCHAR_MAX=255. Thus it prints 290 % (UCHAR_MAX+1)=34