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

why & sign is used in copy constructor

4 Answers  


In what scenario does the Logical file and Physical file being used?

0 Answers   informatics,


a program using one dimensional array that searches a number if it is found on the list of given input numbers given by the user and locate its exact location in the list.

0 Answers  


What are stl algorithms?

0 Answers  


Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.

0 Answers  






how to get the sum of two integers?

2 Answers  


Is stl open source?

0 Answers  


Q1. A. What is unary operator? List out the different operators involved in the unary operator. B. What is an adjust field format flag? Q2. A. Distinguish between a # include and #define. B. Can a list of string be stored within a two dimensional array? Q3. A.Explain how a pointer to function can be declared in C++? B.List the merits and demerits of declaring a nested class in C++? Q4. A. What are the syntactic rules to be avoid ambiguity in multiple inheritence? B. Explain the operation of overloading of an assignment operator. Q5. A. Explain how the virtual base class is different from the conventional base classes of the opps. B. Explain how an exception handler is defined and invoked in a Program. Q6. A. What is a binary file? List the merits and demerits of the binary file usagein C++. B. Write short notes on Text Manipulation Routines. C. Write bites in Turbo c++ Header (“Include”) Files.

0 Answers   GE, Infosys, Microsoft, NIM,


What are the components of stl?

0 Answers  


What Is Operator Overloading in C++?

3 Answers  


HOW TO GET "H1B" -VISA 4 USA FOR MY SON?HE HAD COMPLETED "MS"(IT)FROM AUSTALIA 2007.I AM WORKING IN U.S.A.

0 Answers  


What is stl in c++ with example?

0 Answers  


Categories