Question: Can you see what i did wrong with my code: code- #include #include #include int main(int argc, char *argv[]) { pid_t pid, pid1; int n;
Can you see what i did wrong with my code:
code-
#include
int main(int argc, char *argv[]) { pid_t pid, pid1; int n;
if (argc == 1) { fprintf(stderr,"Usage: %s
return -1; }
n = atoi(argv[1]);
/* add your code below, following the code structure of Figure 3.34 (page 152) */ pid = fork(); if (pid
while (n != 1) {
scanf("%d",&n); printf("%d, ", n); if (n % 2 > 0) n = 3 * n + 1; else n = n / 2; } printf("1 ");
return 0; }
error-![#include #include int main(int argc, char *argv[]) { pid_t pid, pid1; int](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66ee8cab3426a_61066ee8caad7391.jpg)
Problem:
![n; if (argc == 1) { fprintf(stderr,"Usage: %s ", argv[0]); return -1;](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66ee8cabf126e_61166ee8cab68b42.jpg)
![} n = atoi(argv[1]); /* add your code below, following the code](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66ee8cacd626c_61266ee8cac3656c.jpg)
Structure of the code:

The code is in c.
make -s nix/store/039g378vc3pc3dvi9dzdlrd0i4q93qwf-binutils-2.39/bin/ld: /tmp/main-ac762c.0: in function 'main': home/runner/ImpartialComposedWatch/./main.c:7: multiple definition of 'main'; /tmp/main-521317.0:/home/runner/ImpartialCom osedWatch/./alt/main.c:7: first defined here lang-12: error: linker command failed with exit code 1 (use -v to see invocation) ake: [Makefile:10: main] Error 1 xit status 2 Problem 1: Programming problem 3.21 (page 155), with the following extra information/requirements: 1. Besides requirements in Problem 3.21, your program should also display the process IDs of both the parent and child processes. Follow the code in Figure 3.34 (page 152) to structure your program and to print the process IDs. Capture a screenshot after running your program. A sample screenshot is provided below (the output of your program should have the same structure as in the sample screenshot). 2. A skeleton of the program is provided in iCollege, which has code to obtain user's input number from command line. Add your own code based on the existing code. 3. You can use the gcc command to compile the program. See the sample screenshot below. What to submit (submit through iCollege): Upload program file hw1.c and a project report (named as "HWl.pdf" or "HW1.doc") to iCollege. The project report should include 1) a sample screenshot of the output; 2) the source code of hwl.c. Sample output screenshot 21 The Collatz conjecture concerns what happens when we take any positive integer n and apply the following algorithm: n={n/2,3n+1,ifnisevenifnisodd The conjecture states that when this algorithm is continually applied, all positive integers will eventually reach 1 . For example, if n=35, the sequence is 35,106,53,160,80,40,20,10,5,16,8,4,2,1 Write a C program using the fork () system call that generates this sequence in the child process. The starting number will be provided from the command line. For example, if 8 is passed as a parameter on the command line, the child process will output 8,4,2,1. Because the parent and child processes have their own copies of the data, it will be necessary for the child to output the sequence. 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 positive integer is passed on the command line. Figure 3.34 What are the pid values
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
