void main()
{
char c;
while(c=getchar()!='\n')
printf("%d",c);
}
o/p=11 why?

Answer Posted / hari.11

above friend has posted correct answer,
11 is not the correct answer,
it will take all characters into buffer and will not output any answer until we press '\n' character.
So it would print 1 as many times as number of character pressed before '\n'.

e.g.:
s
o/p: 1

sd
o/p: 11

gdfdd
o/p: 11111

111
o/p: 111


for further queries and discussions, visit..

http://forum.campusmaniac.com/
http://www.campusmaniac.com/

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Wt are the Buses in C Language

2753


What is wrong in this statement?

608


How can I find out how much free space is available on disk?

632


How can I insert or delete a line (or record) in the middle of a file?

579


What is a list in c?

624






Explain what are reserved words?

638


List a few unconditional control statement in c.

564


What does emoji p mean?

610


What is the function of this pointer?

679


What are local static variables?

622


Explain how can I convert a string to a number?

647


How is = symbol different from == symbol in c programming?

618


what is the function of pragma directive in c?

632


When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?

811


Is it fine to write void main () or main () in c?

549