main()
{
printf(5+"good morning");
printf("%c","abcdefgh"[4]);
}the o/p is morning and e...how someone explain



main() { printf(5+"good morning"); printf("%c","abcdefgh"[4]); }th..

Answer / vignesh1988i

the o/p depends upon the compiler and cant be predicted
wat's hapenning inside .... each will have different
opinion.....my opinion is :
here in the first printf statement "good morning" acts as
an string and 5+"good morning" means print the string
after the 5th character in the string starting from 0....
so o/p is :
morning

for second one :

this printf can be re-written as the first printf statement
printf("%c",4+"abcdefgh");
here only the 4th character will get printed ... in this
case it will print 'e'..

thank u

Is This Answer Correct ?    26 Yes 11 No

Post New Answer

More C Interview Questions

how to make program without <> in library.

1 Answers   ADITI,


What does %f mean c?

1 Answers  


though sbi was nationalized why its not comes under nationalized banks and its comes under publicsector banks

3 Answers   State Bank Of India SBI,


Why c++ is called c++ and not c+?

9 Answers   EBS,


Is linux written in c?

1 Answers  


I heard that you have to include stdio.h before calling printf. Why?

1 Answers  


Explain how do I determine whether a character is numeric, alphabetic, and so on?

1 Answers  


Who is the founder of c language?

1 Answers  


Determine the code below, tell me exactly how many times is the operation sum++ performed ? for ( i = 0; i < 100; i++ ) for ( j = 100; j > 100 - i; j--) sum++;

5 Answers   ITCO, Wipro,


How can I read and write comma-delimited text?

1 Answers  


Explain what happens if you free a pointer twice?

1 Answers  


Which of these statements are false w.r.t File Functions? i)fputs() ii)fdopen() iii)fgetpos() iv)ferror() A)ii B)i,ii C)iii D)iv

6 Answers   Accenture,


Categories