what will be printed by this printf?
printf("%c",printf("hi")["sharkselva"]));
}
Answers were Sorted based on User's Feedback
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 is Conio.h ?
What is the relationship between pointers and data structure?
What is enumerated data type in c?
What is the purpose of macro in C language?
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....
What are the properties of union in c?
what are the stoge class in C and tel the scope and life time of it?
write a program that types this pattern: 12345678987654321 12345678 87654321 1234567 7654321 123456 654321 12345 54321 1234 4321 123 321 12 21 1 1
Which type of language is c?
Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?
What is the purpose of type declarations?
What is unary operator?