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
Why is %d used in c?
What are the advantage of c language?
What does the error message "DGROUP exceeds 64K" mean?
What is a method in c?
any function have arguments one or more OR not . it is compulsary a) any function compulsary have one or more arguments b) any function did not have arguments. It is not compulsary c) it is optional it is not compulsary d) none of the above
What are valid operations on pointers?
Are the outer parentheses in return statements really optional?
What are the types of operators in c?
What is quick sort in c?
What is the scope of local variable in c?
a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above
Which is better pointer or array?
How can you check to see whether a symbol is defined?
a=10;b= 5;c=3;d=3; if(a printf(%d %d %d %d a,b,c,d) else printf("%d %d %d %d a,b,c,d);
Sir i need notes for structure,functions,pointers in c language can you help me please