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

What are the 5 types of organizational structures?

543


Explain about the constants which help in debugging?

841


How many bytes is a struct in c?

719


how to find binary of number?

3413


How can I do serial ("comm") port I/O?

681






What is static volatile in c?

568


What are control structures? What are the different types?

588


What are the uses of a pointer?

672


What is optimization in c?

562


Write a program that takes a 5 digit number and calculates 2 power that number and prints it(should not use big integers and exponential functions)

5784


Tell me when would you use a pointer to a function?

599


What is use of bit field?

762


Are pointers integers in c?

602


Are the variables argc and argv are local to main?

780


State the difference between x3 and x[3].

648