Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute CLA-11-03 Exam - Topic 3 Question 5 Discussion

Posted by Emiko on Sep 27, 2026 at 01:47 AM

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:

Suggested Answer: A

* 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.


Get Premium CLA-11-03 Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
4 comments · newest first
LI
Lindsey 3 days ago
I’m confused about the char type here. Does it affect the output if the value exceeds the typical range? I feel like it could fail to compile.
AL
Alfreda 8 days ago
I practiced a similar question where the output was affected by base conversions. I think this one might compile but give an unexpected result.
BU
Buddy 13 days ago
I remember something about octal and hexadecimal, but I can't recall how they convert to decimal. I feel like it might be 68.
SH
Sherman 18 days ago
I think the program will compile fine, but I'm not sure what the output will be since it has different number bases.
0/2000 characters

Save Cancel