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

which type of aspect you want from the student.

1701


how do you programme Carrier Sense Multiple Access

1510


Difference between pass by reference and pass by value?

656


What is 'bus error'?

641


Why doesnt the call scanf work?

665






What is the general form of a C program?

596


What is chain pointer in c?

599


What is the -> in c?

579


Does sprintf put null character?

596


What is function what are the types of function?

554


Ow can I insert or delete a line (or record) in the middle of a file?

570


Explain what is the difference between text files and binary files?

612


Write a program to check palindrome number in c programming?

596


Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?

596


How many identifiers are there in c?

576