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


Please Help Members By Posting Answers For Below Questions

Why is %d used in c?

757


What are the advantage of c language?

785


What does the error message "DGROUP exceeds 64K" mean?

996


What is a method in c?

832


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

873


What are valid operations on pointers?

958


Are the outer parentheses in return statements really optional?

843


What are the types of operators in c?

815


What is quick sort in c?

830


What is the scope of local variable in c?

804


a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above

885


Which is better pointer or array?

812


How can you check to see whether a symbol is defined?

835


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);

869


Sir i need notes for structure,functions,pointers in c language can you help me please

2188