0% found this document useful (0 votes)
8 views1 page

Lab Fork

Uploaded by

batoolzain077
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Lab Fork

Uploaded by

batoolzain077
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Lab 1: Fork ()

• Objective:
✓ Understand the basic concept of process creation in Unix-like operating
systems using the fork() system call.
✓ Recognize that fork() creates an identical copy of the calling process, resulting
in both parent and child processes continuing from the same point.

• Lab Environment:
Use a system running Red Hat Enterprise Linux or a similar Linux distribution.
Tasks:

1-Calculate the Sum of Two Numbers


Write a C program that prompts the user to enter two integer numbers. The program should use
the fork () system call to create a child process.
• In the child process, calculate the sum of the two numbers, print the result of the
summation.
• In the parent process, print a message indicating the completion

2- Odd or Even
Write a C program that prompts the user to enter an integer. Use the fork() system call to create
a child process.
• In the child process, determine if the entered number is odd or even. Print the result in
the child process.
• In the parent process, wait for the child to complete and print a message indicating the
completion

You might also like