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

Write a function in c to find the area of a triangle whose length of three sides is given.

2 Answers  


What is the size of enum in c?

0 Answers  


Write the following function in C. stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.

4 Answers   OpenFeel,


What are different storage class specifiers in c?

0 Answers  


void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }

3 Answers   ME, pspl,






triangle number finding program...

1 Answers   HCL,


What are c preprocessors?

0 Answers  


Does c have circular shift operators?

0 Answers  


what will be the output of "printf("%d%d",scanf("%d% d",&a,&b))".provide an explation regarding the question

6 Answers  


How can I manipulate individual bits?

0 Answers  


What is n in c?

0 Answers  


Difference between constant pointer and pointer to a constant.

0 Answers   Huawei,


Categories