Give the output of the following program
main()
{int ret;
ret=fork();ret=fork();ret=fork();ret=fork();
if(!ret)
printf("sun");
else
printf("solaris");
Answers were Sorted based on User's Feedback
Answer / rojoco
Imagining that the correct headers were included and the
closing bracket for the main function is added, it'll print
sun 8 times and solaris 8 times. You won't know the order
that they're printed in, it depends on the kernel scheduler
as to which process is run first.
| Is This Answer Correct ? | 11 Yes | 1 No |
Answer / imran
I dont't think this will compile as its missing a closing
brace.
| Is This Answer Correct ? | 13 Yes | 5 No |
Answer / anupam mittal
The ans depend on the value returned by the fork function
there is no fork function defined so we can not predict he
ans
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / pdp
It depends on the return value of fork(). If it is other
than 0 (zero), then the output is solaris else sun.
| Is This Answer Correct ? | 6 Yes | 5 No |
Answer / prasanna
It will print solaris first and then sun... A sequence of
solarissun if there is a closing brace at the end..!!
| Is This Answer Correct ? | 1 Yes | 4 No |
Answer / saurabh singh
first of all it will not execute bec of 2 reasons:
1.it doesn't have a closing braces.
2.fork() function is not defined anywhere.so it will show
an error.
| Is This Answer Correct ? | 2 Yes | 5 No |
write a program that input four digit number and find how many 7 that number contains
What is Object Oriental Progam
What are stl algorithms?
write a piece of c++ code which allocate memory to the 50 object of type CObj
Define the terms: field, record, table and database
write a program that will accept a number and print.its equivalent in words the maximum input number is 9999
What is a standard template library (stl)?
what's the difference between function overloading and function overiding?
What is the disadvantage of templates ?
Find the error in the following program struct point {struct point *next; int data; } x; main() {int...data; } x; main() {int i; for(x=p;x!=0;) x=x->next,x++; freelist(x); } freelist(x) {free(x); return }
Who created stl?
write a c++ to define a class box with length,breadth and height as data member and input value(),printvalue() and volume() as member functions.