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

Why we not create function inside function.

1742


explain what is a newline escape sequence?

678


What is the importance of c in your views?

586


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

582


Explain how do you convert strings to numbers in c?

590






When can a far pointer be used?

584


What is volatile variable in c?

652


why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above

647


How the c program is executed?

624


1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. 2) the Event Manager has to send participants to the stage to perform in the order in which they registered. Write a program that will help the Event Manager know who to call to the stage to perform. The Logic should be in Data Structures

2735


Explain how can you be sure that a program follows the ansi c standard?

852


Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above

654


How to throw some light on the b tree?

600


What's the best way of making my program efficient?

618


how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?

1501