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 are bit fields? What is the use of bit fields in a structure declaration?
Why string is used in c?
Are the variables argc and argv are local to main?
What is use of null pointer in c?
Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
Explain the difference between malloc() and calloc() function?
Where local variables are stored in c?
Are there any problems with performing mathematical operations on different variable types?
What is difference between function overloading and operator overloading?
List the difference between a While & Do While loops?
In a header file whether functions are declared or defined?
Write a program to use switch statement.
Does * p ++ increment p or what it points to?
Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)
Study the following C program :call_me (myvar)int myvar;{ myvar +- 5; }main(){int myvar;myvar = 3;call_me(myvar);printf("%d ",myvar);What will be printed a) 3 b) 5 c) 8 d) symbol