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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a string?

666


Why is it that not all header files are declared in every C program?

683


Why does everyone say not to use gets?

610


Why enum is used in c?

524


Explain what does the function toupper() do?

636






How can I read in an object file and jump to locations in it?

579


What is a scope resolution operator in c?

751


How can you pass an array to a function by value?

600


Can you tell me how to check whether a linked list is circular?

770


What is the maximum no. of arguments that can be given in a command line in C.?

668


What is the scope of an external variable in c?

569


why arguments can generally be passed to functions a) sending the values of the arguments b) sending the addresses of the arguments c) a & b d) none of the above

645


Why #include is used in c language?

601


Explain what is the benefit of using const for declaring constants?

614


What kind of structure is a house?

557