121. Data Conversion and Encoding-i

Question.3

A developer converts a binary configuration string to an integer:

char *s = "1101";
int val = 0;
for (int i = 0; s[i]; i++)
   val = (val << 1) | (s[i] - '0');
printf("%d", val);

What is the output?

Need Help? Refer to the Quick Guide below

Select Answer