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 the Output? int a=4 b=3; printf("%d%d%d%d%d%d",a++,++a,a++,a++,++a,a++); printf("%d%d%d%d%d%d",b--,b--,--b,b--,--b,--b);

10 Answers   IBM,


what is difference between procedural language and functional language ?

4 Answers   Wipro,


What is the use of a ‘’ character?

0 Answers  


Explain the difference between malloc() and calloc() in c?

0 Answers  


what is the c source code for the below output? 5555555555 4444 4444 333 333 22 22 1 1 22 22 333 333 4444 4444 5555555555

0 Answers   Wipro,






what is the difference between these initializations? Char a[]=”string”; Char *p=”literal”; Does *p++ increment p, or what it points to?

4 Answers  


show how link list can be used to repersent the following polynomial i) 5x+2

0 Answers   CBSE,


Find Index of least significant bit set in an Integer. ex. int value is say 10001000 results should be 4.

1 Answers  


Why doesn't C have nested functions?

2 Answers  


what is the use of using linked list and array?

10 Answers   Infosys, TCS,


What is array of structure in c?

0 Answers  


write a program to insert an element at the specified position in the given array in c language

5 Answers   Appin, IBM,


Categories