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

What is structure in c definition?

580


FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above

628


Is multithreading possible in c?

574


Is c easy to learn?

566


Explain what are linked list?

629






How will you write a code for accessing the length of an array without assigning it to another variable?

623


A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(

1749


The __________ attribute is used to announce variables based on definitions of columns in a table?

679


Are the expressions * ptr ++ and ++ * ptr same?

674


differentiate built-in functions and user – defined functions.

640


Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

683


c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above

624


What is a null string in c?

596


what is the syallabus of computer science students in group- 1?

1847


What is the difference between memcpy and memmove?

611