Exam CLA-11-03 Topic 1 Question 29 Discussion
Actual exam question for C++ Institute's CLA-11-03 exam
Question #: 29
Topic #: 1
Question #: 29
Topic #: 1
What happens if you try to compile and run this program?
#include <stdio.h>
int main (int argc, char *argv[]) {
char i = 20 + 020 + 0x20;
printf("%d",i);
return 0;
}
Choose the right answer:
#include <stdio.h>
int main (int argc, char *argv[]) {
char i = 20 + 020 + 0x20;
printf("%d",i);
return 0;
}
Choose the right answer:
Suggested Answer: A Vote an 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:
o20 is a decimal literal with the value 20
o020 is an octal literal with the value 16 (8^1 * 2 + 8^0 * 0)
o0x20 is a hexadecimal literal with the value 32 (16^1 * 2 + 16^0 * 0)
oThe + 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.
*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:
o20 is a decimal literal with the value 20
o020 is an octal literal with the value 16 (8^1 * 2 + 8^0 * 0)
o0x20 is a hexadecimal literal with the value 32 (16^1 * 2 + 16^0 * 0)
oThe + 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.
by Novia at Aug 05, 2025, 09:26 AM
0
0
0
10
Comments
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Report Comment
Commenting
You can sign-up / login (it's free).