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

what is c++

2 Answers  


How the STL's are implemented, What the difference between templates and STL?

1 Answers   Symphony,


What is the stl, standard template library?

0 Answers  


write a program to demonstrate,how constructor and deconstructor work under multilevel inheritance

3 Answers   TCS,


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

1 Answers  






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 }

1 Answers   Sun Microsystems,


write a program that input four digit no and finds it is palindrome or not

2 Answers  


What is Object Oriental Progam

2 Answers  


WHAT IS THE DIFFERENCE BETWEEN C++ AND VC++

1 Answers   Syntel,


Question 1)Read the data from one file and remove all the duplicated words and generate an output file containg only using words.Program should also print number of occurance of each words on standard output.(Program must be use STL and iostream object). Question 2)Write a program to convert the lower case contents of file to upper case using STL. Question 3)What is the output of this problem. int i=12; int &r =i; r+r/4; int +p =&r; int *p = &r; P+=r; return 1; Answer :a)12 b)17 c) 30 d)24 E)15 Question 4) #include #include #include void main() { char srcstr[30],desstr[30]; int i,len; clrscr(); cout<<"\nenter the string\n"; cin>>srcstr; len=strlen(srcstr); for(i=0;srcstr[i]!='\0';i++) { desstr[--len]=srcstr[i]; } desstr[i]='\0'; cout<<"\nreversed string is\n"; for(i=0;desstr[i]!='\0';i++) { cout< } getch(); } Answer : A) string output b)tuptuo gnirts c) string d)output Question 5) Class Test { static const Tk=LEN; int q; public: foo(intx =LEN):q(x){}; TGet Q() const { return q:} void call test Foo<long :9> foo(10); std::const<< foo.Getq(); Answer: 7,8,9,10,11 question 6) class A { int a; char b; }; class B:public A { char b; int a; }; What is the size? Answer a)5 bytes for class A and 5 bytes class B b)4 bytes for class A and 8 bytes class B. c).... d)....

2 Answers   Bally Technologies,


Can we use stl in coding interviews?

0 Answers  


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

1 Answers  


Categories