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 Conio.h ?

2 Answers   TCS,


What is the relationship between pointers and data structure?

0 Answers  


What is enumerated data type in c?

0 Answers  


What is the purpose of macro in C language?

0 Answers   Fidelity,


I use turbo C which allocates 2 bytes for integers and 4 bytes for long. I tried to declare array of size 500000 of long type using the following code... long *arr; arr=(long *)(malloc)(500000 * sizeof(long)); It gives a warning that "Conversion may lose significant digits in function main"... And the resulting array size was very less around 8400 as compared to 500000. Any suggestions will be welcomed....

2 Answers  






What are the properties of union in c?

0 Answers  


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

2 Answers   Tech Mahindra,


write a program that types this pattern: 12345678987654321 12345678 87654321 1234567 7654321 123456 654321 12345 54321 1234 4321 123 321 12 21 1 1

0 Answers  


Which type of language is c?

0 Answers  


Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?

0 Answers  


What is the purpose of type declarations?

0 Answers  


What is unary operator?

0 Answers  


Categories