what will be printed by this printf?
printf("%c",printf("hi")["sharkselva"]));
}
Answer Posted / 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 |
Post New Answer View All Answers
What is the difference between malloc calloc and realloc in c?
Can you explain the four storage classes in C?
Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?
What are static variables in c?
How do you print only part of a string?
How many types of arrays are there in c?
What is the usage of the pointer in c?
How can I remove the trailing spaces from a string?
What is a union?
An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above
What is the purpose of 'register' keyword?
stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.
How can you draw circles in C?
Array is an lvalue or not?
how is the examination pattern?