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

Is the below things valid & where it will be stored in memory layout ? static const volatile int i; register struct { } ; static register;

2 Answers   Lucent,


printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions

0 Answers  


What are pointers in C? Give an example where to illustrate their significance.

0 Answers   Wipro,


write a programe to find the factorial of given number using recursion

3 Answers  


What does the message "warning: macro replacement within a string literal" mean?

1 Answers  






what is the advantage of software development

1 Answers  


how to find a 5th bit is set in c program

4 Answers   IBM,


There seem to be a few missing operators ..

0 Answers  


x=y=z=1 z=++x||++y&&++z Printf("%%%d";xyz) what is the values of x,y and z?????

3 Answers  


how to TOGGLE Nth bit of variable in a MACRO

1 Answers   NDS,


what's the o/p int main(int n, char *argv[]) { char *s= *++argv; puts(s); exit(0); }

1 Answers   Motorola,


Is it fine to write void main () or main () in c?

0 Answers  


Categories