GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Placement Papers  >  Honey Well  >  C

 Print  |  
Question:  Honey Well Written Test -  C Questions

Answer:

I did not attempted the C paper but still I just had a look on C and java paper.  in C most of the question were programs and their out was  asked in LINUX environment.

1)
      int main()
      {
      char *a= "Novell";
      char  *b;
      b=malloc(10*sizeof(char));
      memset(b,0,10);
      while(*b++=*a++);
      printf("%s",b);
      return 0;
      }
2) int main()
     {
     printf("Hello");
     fork();
     printf("World");
     }



June 06, 2006 02:48:14 #2
 ramubeedhimane   Member Since: Visitor    Total Comments: N/A 

RE: Honey Well Written Test -  C Question...
 

for 2nd question,

o/p - helloworldhelloworld. ( this is the case on linux)

because, execution of  first printf statment stores in buffer. 

fork , forks helloworld. thats why, its print 2 times helloworld.

In case if u placed "\n" line buffer in first printf .

like : printf("hello\n"); directly prints on standard buffer.

thats the reson it only forks the second printf.

o/p - hello

  world world 

     

 

Back To Question