BLACK FRIDAY SALE – Unlock Up to 25% OFF on All Exam Prep! - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute CLA-11-03 Exam - Topic 2 Question 4 Discussion

Posted by Annabelle on Sep 26, 2026 at 08:24 AM

What happens if you try to compile and run this program?

#include

int main (int argc, char *argv[]) {

int i = 2;

int d= i << 2;

d /= 2;

printf ("%d", d) ;

return 0;

}

Choose the right answer:

Suggested Answer: B

The program outputs 4 because the expression i << 2 performs a left shift operation on the binary representation of i, which is 00000010, by two bits, resulting in 00001000, which is equivalent to 8 in decimal. Then, the expression d /= 2 performs a division assignment operation, which divides d by 2 and assigns the result back to d, resulting in 4. The printf function then prints the value of d as a decimal integer using the %d format specifier.

Reference = CLA -- C Certified Associate Programmer Certification, [C Essentials 2 - (Intermediate)], C Bitwise Operators, C Assignment Operators


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
13 comments · newest first
PH
Phyliss 2 days ago
Nope, it's definitely 4. Shift left and divide!
CA
Cassi 7 days ago
Wait, are you sure? I thought it would be 2.
AN
Anglea 12 days ago
Totally agree, it's a bit of bitwise magic!
DO
Dona 17 days ago
The program outputs 4.
FE
Felice 22 days ago
I thought it would be 2, but I see the logic now.
BE
Ben 27 days ago
No way it outputs 0, that's just wrong!
VA
Valentin 1 month ago
Wait, how does the bit shift work again?
DE
Desmond 1 month ago
Totally agree, it's a bit straightforward.
VE
Verlene 1 month ago
The program outputs 4.
EV
Evette 2 months ago
I’m confused about the output. I thought left shifting would just add zeros, but I guess it’s actually multiplying by powers of two?
LE
Lenny 2 months ago
I practiced a similar question, and I feel like the output should be 4, but I could be wrong about the shift operation.
TR
Truman 2 months ago
I'm not entirely sure, but I remember something about division in C. Wouldn't `d /= 2` make it 4?
MI
Mindy 2 months ago
I think the left shift operator will double the value of `i`, so `d` should be 8 after the shift.
0/2000 characters

Save Cancel