What happens if you try to compile and run this program?
#include
int main (int argc, char *argv[]) {
char i = 20 + 020 + 0x20;
printf("%d",i);
return 0;
}
Choose the right answer:
* The program is a valid C program that can be compiled and run without errors.
* The variable i is declared as a char, which is an 8-bit signed integer type that can store val-ues from -128 to 127.
* The expression 20 + 020 + 0x20 evaluates to 68, because:
o 20 is a decimal literal with the value 20
o 020 is an octal literal with the value 16 (8^1 * 2 + 8^0 * 0)
o 0x20 is a hexadecimal literal with the value 32 (16^1 * 2 + 16^0 * 0)
o The + operator performs arithmetic addition on the operands and returns the sum
* The printf function prints the value of i as a decimal integer using the %d format specifier.
* The output of the program is 68.
Currently there are no comments in this discussion, be the first to comment!