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

Write a routine that prints out a 2-D array in spiral order!

1 Answers   Lucent,


i want to make a program in which we use input having four digits(4321) and get output its reciprocal(1234).

1 Answers  


What is the use of the function in c?

1 Answers  


what is difference between ++(*p) and (*p)++

17 Answers   Accenture, HCL, IBM,


Rapunzel walks into the forest of forgetfullness. She meets a Lion who lies on Monday Tuesdays and Wednesdays and meets a rabbit who lies on Thurs fridays and saturdays . On that day both say that "I lied yesterday". What day is it .

3 Answers   TCS,


What is bubble sort in c?

1 Answers  


What do you mean by keywords in c?

1 Answers  


Why c is called a middle level language?

1 Answers  


write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays

1 Answers   IBM,


Difference between malloc() and calloc() function?

1 Answers  


How can you invoke another program from within a C program?

1 Answers  


How to delete a node from linked list w/o using collectons?

1 Answers   Zycus Infotech,


Categories