Determine output : main(){ int i=012; int j=046; int k=056; printf("i=%d",i); printf("j=%d",j); printf("k=%d",k);}

  1. 012046056

  2. 124656

  3. 103846

  4. 010038046


Correct Option: C

AI Explanation

To determine the output of the given code, let's go through each line:

int i=012;

In C, a number starting with a leading 0 is considered an octal (base 8) number. Therefore, 012 is interpreted as the octal value 12, which is equivalent to the decimal value 10.

int j=046;

Similarly, 046 is an octal number. In this case, it is equivalent to the decimal value 38.

int k=056;

Once again, 056 is an octal number, which is equal to the decimal value 46.

printf("i=%d",i);

This line uses the printf function to print the value of i as a decimal number. Since i is 10, the output will be "i=10".

printf("j=%d",j);

Similarly, this line prints the value of j as a decimal number. Since j is 38, the output will be "j=38".

printf("k=%d",k);

Again, this line prints the value of k as a decimal number. Since k is 46, the output will be "k=46".

Therefore, the correct answer is C) 103846.

Find more quizzes: