To determine the output of the given code, let's go through each step:
#include
int main() {
int i=43;
printf("%d\n", printf("%d", printf("%d", i)));
return 0;
}
The printf
function in C returns the number of characters printed. So, let's break down the code step by step:
printf("%d", i)
will print 43
and return 2
(the number of characters printed).
printf("%d", printf("%d", i))
will print the result of the previous printf
statement, which is 2
, and return 1
(the number of characters printed).
printf("%d\n", printf("%d", printf("%d", i)))
will print the result of the previous printf
statement, which is 1
, and return 1
(the number of characters printed).
Therefore, the output of the code will be 4321
.
So, the correct answer is B) 4321.