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

Hai friends im a i year student. i want to develop my knowledge in the field of TSR in c. How I'm Improve ?

2 Answers  


Process by which one bit pattern in to another by bit wise operation is?

0 Answers   InterGraph,


What is header file in c?

0 Answers  


what is the difference between char * const and const char *?

2 Answers   TCS,


Convert the following expression to postfix and prefix X $ Y Z - M + N + P / Q / (R + S)

2 Answers  






The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?

0 Answers  


what is the full form of c language

9 Answers   Satyam, TCS, VNC,


There is a mobile keypad with numbers 0-9 and alphabets on it. take input of 7 keys and then form a word from the alphabets present on those keys.

0 Answers  


What is variable in c with example?

1 Answers  


Difference between null pointer and dangling pointer?

7 Answers   GE, Wipro,


Why array is used in c?

0 Answers  


Is that possible to add pointers to each other?

0 Answers  


Categories