what will be printed by this printf?
printf("%c",printf("hi")["sharkselva"]));
}

Answers were Sorted based on User's Feedback



what will be printed by this printf? printf("%c",printf("hi")["sharkselva&..

Answer / vadivelt

Ans: hia

Reason is, in the below statement,
printf("%c",printf("hi")["sharkselva"]));

printf("hi") shall be executed first. and this printf will
return the value 2. ie., no of characters successfully
printed by printf()statement.

So in runtime, "printf("%c",printf("hi")["sharkselva"]));"
will print "hi" and after, the main printf shall be
replaced as "printf("%c",2["sharkselva"]));".

According to printf() implementation, printf("%c",2
["sharkselva"]));" has to print the value at the array, for
the index given ie., 2. So in the array index '2',
character 'a' is available.

Now a is printed.

So the total output will be -> hia

Is This Answer Correct ?    31 Yes 1 No

what will be printed by this printf? printf("%c",printf("hi")["sharkselva&..

Answer / ramesh choudhury

hia

Is This Answer Correct ?    9 Yes 1 No

what will be printed by this printf? printf("%c",printf("hi")["sharkselva&..

Answer / srsabariselvan3

hia

Is This Answer Correct ?    9 Yes 2 No

Post New Answer

More C Interview Questions

What is c programming structure?

0 Answers  


Where is volatile variable stored?

0 Answers  


Differentiate abs() function from fabs() function.

0 Answers  


What are the applications of c language?

0 Answers  


21. #define square(x) x*x main() { int i; i = 64/square(4); printf("%d",i); }

3 Answers  






how to swap two integers 1 and 32767 without using third variable

11 Answers   Microsoft, TCS,


How many levels of indirection in pointers can you have in a single declaration?

0 Answers   Agilent, ZS Associates,


what is the flow of execution in cprogram? ex:printf();,scanf();

2 Answers  


What is unsigned int in c?

0 Answers  


Why is c so popular?

0 Answers  


what are the stoge class in C and tel the scope and life time of it?

2 Answers   Tech Mahindra,


What does %p mean?

0 Answers  


Categories