Assuming that the code was compiled and ran in Unix/Linux environment what is its expected output?

Last Updated on May 6, 2022 by Admin 3

Assuming that the code was compiled and ran in Unix/Linux environment what is its expected output?

#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <unistd.h>
int x = 0;
int main(void) {
    if(fork()){
      wait(NULL);
         printf("%d", x);
      return 0;
    }else{
            x++;
          return 0;
    }
}
  • 2
  • 1
  • 0
  • an empty line
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments