Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6745267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:11:03+00:00 2026-05-26T12:11:03+00:00

I have homework that should use fork() and wait() system calls: 1) Write two

  • 0

I have homework that should use fork() and wait() system calls:

1) Write two C programs using the fork() system call that generate the following in the child process:
a) Fibonacci sequence for m number provided in the command line (what is the only task I actually did:)

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h> 
int main() {
      int a=0, b=1, n=a+b,i,ii;
      pid_t pid;
      printf("Enter the number of a Fibonacci Sequence:\n");
      scanf("%d", &ii);
      if (ii < 0)
          printf("Please enter a non-negative integer!\n");
      else    {
          pid = fork();
      if (pid == 0)
      {
         printf("Child is producing the Fibonacci Sequence...\n");
         printf("%d %d",a,b);
         for (i=0;i<ii;i++)
         {
            n=a+b;
            printf("%d ", n);
            a=b;
            b=n;
         }
         printf("Child ends\n"); 
      }
      else 
      {
         printf("Parent is waiting for child to complete...\n");
         wait(NULL);
         printf("Parent ends\n");
      }    }    return 0; }

b) quicksort of the n numbers provided from the command line (I don’t know if I just have to write quicksort algorithm or implement fork() or I don’t know anymore?)

For both programs have the parent invoke the wait() call to wait for the child process to complete before exiting the program. Perform necessary error checking to ensure that a non-negative number is passed on the command line.

2) Merge the above two programs (this is what about I have no idea how to do) into one, where one parent process will fork two child processes, one for the Fibonacci sequence, and the other for quicksort. The input to your program should be taken from command line arguments. Your source program must be named as merge.c. The command line looks like the following:
merge m n
Here, m and n are two positive integers. Thus your program should generate m random integers (this is what I also have no idea, generating random numbers in C) and sort them with quicksort, and compute the n-th Fibonacci number. The output should be as follows:

*Quicksort Process Started
Random Numbers Generated
6 8 3 10 25 5 2 30
Sorted Sequence
2 3 5 6 8 10 25 30
Quicksort Process Exits*

I need quick help 🙁 thank youuuu 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:11:03+00:00Added an answer on May 26, 2026 at 12:11 pm

    Your first program seems basically correct. You’ll make your life a little easier if you make the Fibonacci part its own function.

    Your quicksort program should be written the same way. Call fork and have the child do the sorting.

    To generate random numbers, use the ‘rand’ function. (Same in C and C++.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've done this function in C using system calls (open, read and write) to
I have homework that I need to make a custom string class using C
I have a homework to do that says the following: Write a program in
I have a compiler homework question that wants me to draw a DFA for
From C Primer Plus 5th Ed: Write a program that creates two eight-element arrays
There is a homework I should do and I need help. I should write
I have a homework project that require the creation of a STATIC library to
It seems that I have to make it in detail; it's my homework. I
I have a homework task to prove whether or not a particular variation on
I have a homework assignment where I need to take input from a file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.