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



Give the output of the following program main() {int ret; ret=fork();ret=fork();ret=fork();ret=fo..

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

Give the output of the following program main() {int ret; ret=fork();ret=fork();ret=fork();ret=fo..

Answer / imran

I dont't think this will compile as its missing a closing
brace.

Is This Answer Correct ?    13 Yes 5 No

Give the output of the following program main() {int ret; ret=fork();ret=fork();ret=fork();ret=fo..

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

Give the output of the following program main() {int ret; ret=fork();ret=fork();ret=fork();ret=fo..

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

Give the output of the following program main() {int ret; ret=fork();ret=fork();ret=fork();ret=fo..

Answer / saif

yes

Is This Answer Correct ?    1 Yes 1 No

Give the output of the following program main() {int ret; ret=fork();ret=fork();ret=fork();ret=fo..

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

Give the output of the following program main() {int ret; ret=fork();ret=fork();ret=fork();ret=fo..

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

Give the output of the following program main() {int ret; ret=fork();ret=fork();ret=fork();ret=fo..

Answer / tajul bashar

sunsolarissunsolarissunsolarissunsol

Is This Answer Correct ?    3 Yes 13 No

Post New Answer

More STL Interview Questions

Which data structure gives efficient search? A. B-tree B. binary tree C. array D. linked list

21 Answers   ABC, Sun Microsystems,


What is the underlying datastructure of map?

5 Answers   BIA, Siemens,


What is a standard template library (stl)?

0 Answers  


What is Template Specialization?

1 Answers   Lucent,


What is a standard template library (stl)? What are the various types of stl containers?

0 Answers  






Is stl part of c++ standard?

0 Answers  


Difference between Structure and Class in C++?

5 Answers   Caritor,


What is stl stack?

0 Answers  


What is the stl, standard template library?

0 Answers  


I am doing my BS.c MATHS CAN I ABLE TO JOIN IN NIIT?

2 Answers  


What is Object Oriental Progam

2 Answers  


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

0 Answers  


Categories