What is the output of the following program
#include<stdio.h>
main()
{
int i=0;
fork();
printf("%d",i++);
fork();
printf("%d",i++);
fork();
wait();
}
Answers were Sorted based on User's Feedback
Answer / raghu
totally 8 processes...so each process will print 0 & 1
output: 0101010101010101
Is This Answer Correct ? | 6 Yes | 1 No |
Answer / sourisengupta
finally we will get 001111.
for the first fork() two 0 will be printed and for secoond
forkk four 1 will be printed.
Is This Answer Correct ? | 4 Yes | 3 No |
Answer / srikanth
print order cannot be predicted.Total 8 process(including
main) first process prints 0,1
the first child prints 0,1 and the other 2 child/grand child
process print 1's (two 1s). The other four child/grand child
process wont print anything (created after printf)
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / vignesh1988i
for first printf it will print 0, for second printf it will
print 1.. and finally i will have a value 2.
Is This Answer Correct ? | 5 Yes | 5 No |
Go through the following code sinippet char a[20]; a="Hello Orcale Test"; will this compile?
21. #define square(x) x*x main() { int i; i = 64/square(4); printf("%d",i); }
Write a program to generate the first n terms in the series --- 9,11,20,31,...,82
main() { float f1=10.5; double db1=10.5 if(f1==db1) printf("a"); else printf("b") }
what are threads ? why they are called light weight processes ? what is the relation between process and threads ?
write a program of palindrome(madam=madam) using pointer?
my name is nani i completed my b-tech in hyd now i want go for interveiw but i dont know the process of software field interveiws plz help me anyone how many rouds there n what rounds plz plz plz help me n where i can get these details
1. main() { printf("%d",printf("HelloSoft")); } Output?
What should be keep precautions while using the recursion method?
what is the main use of c where it can use the c
output for following code??? main() { int x=2,y,z; x*=3+2; printf("1.%d\n",x); x*=y=z=4; printf("2.%d %d %d\n",x,y,z); x=y==z; printf("3.%d\n",x); x==(y=z); printf("%d",x); }
Q.1 write aprogram to stack using linklist o insert 40 items? Q.2 write a program to implement circular queue with help of linklist?