Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
635 views
in Information Technology by (114k points)
closed by

Identify the output of the following C code snippet.

#include

#include

#include

int main()

{

fork();

printf ("Test 91!\n");

return 0;


1. Test 91! Test 91!
2. Test 91!
3. Hello 91!
4.

Test 91!

Test 91!

1 Answer

0 votes
by (115k points)
selected by
 
Best answer
Correct Answer - Option 4 :

Test 91!

Test 91!


Concept :

  • In computing, particularly in the context of the Unix operating system and its work likes, fork is an operation whereby a process creates a copy of itself.
  • It is usually a system call, implemented in the kernel.
  • The fork is the primary (and historically, only) method of process creation on Unix - like operating systems.

Explanation:

The purpose of fork() is to create a new process, which becomes the child process of the caller. After a new child process is created, both processes will execute the next instruction following the fork() system call.

So the system will execute the print statements 2 times.

Hence we will get output as:

Test 91!

Test 91!

Hence option (4) is the correct answer.

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...