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

Write a program in C++ returning starting locations of a substring using pointers

1 Answers  


If P is the population on the first day of the year, B is the birth rate, and D is the death rate, the estimated population at the end of the year is given by the formula: The population growth rate is given by the formula: B – D Write a program that prompts the user to enter the starting population, birth and death rates, and n, the number of years. The program should then calculate and print the estimated population after n years. Your program must have at least the following functions: 1. growthRate: This function takes its parameters the birth and death rates, and it returns the population growth rate. 2. estimatedPopulation: This function takes its parameters the current population, population growth rate, and n, the number of years. It returns the estimated population after n years Your program should not accept a negative birth rate, negative death rate, or a population less than 2. please answer my question ....

0 Answers   Microsoft,


what is strcture i++ i ++i answer to this i=5 what is the out put

6 Answers  


What are the components of stl?

0 Answers  


write a program that will accept a number and print.its equivalent in words the maximum input number is 9999

0 Answers  


Explain stl.

0 Answers  


Explain how to insert a hyperlink in to an Excel worksheet and save a Word document as a Web page.

1 Answers  


How to write a function that goes through an array of characters and eliminates any elements that are not letters (Legal letters can be either in an uppercase or a lowercase format.) The function removeNonLetters should return the new effective size of the array as the result.

2 Answers  


what's the difference between abstract class and concreate class? what's the meaning of standard template library(STL)?

6 Answers  


why we are using the fork command?.. how it works?

1 Answers  


if x<>=z then statement end what is the cyclomatic complexity

5 Answers  


How can you create a bulleted list, numbered list and an outline by using bullets and numbering command. Explain with the help of example.

0 Answers  


Categories