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 |
Is the below things valid & where it will be stored in memory layout ? static const volatile int i; register struct { } ; static register;
printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions
What are pointers in C? Give an example where to illustrate their significance.
write a programe to find the factorial of given number using recursion
What does the message "warning: macro replacement within a string literal" mean?
what is the advantage of software development
how to find a 5th bit is set in c program
There seem to be a few missing operators ..
x=y=z=1 z=++x||++y&&++z Printf("%%%d";xyz) what is the values of x,y and z?????
how to TOGGLE Nth bit of variable in a MACRO
what's the o/p int main(int n, char *argv[]) { char *s= *++argv; puts(s); exit(0); }
Is it fine to write void main () or main () in c?