Question: write the code in c , dont chat gpt For this question, create a folder q 3 which should contain the following files: 1 .

write the code in c, dont chat gpt
For this question, create a folder q3 which should contain the following files:
1. date.c: Contains a simple implementation of the date command. This
program should print the current date in at least three different formats. The
user can pass options/flags to specify the desired format (e.g.,-u for UTC, -r
for RFC 2822 format). If no flag is passed, it should print the default date and
time format.
2. cal.c: Contains a simple implementation of the cal command using Zeller's
congruence. The program should take month and year as arguments and
calculate the first day of the month using the formula for the Gregorian
calendar. If the month and year are not provided, it should print an error
message. Use Zellers congruence to determine the first day of the given
month and construct the rest of the month.
3. uptime.c: Contains a simple implementation of the uptime command. This
program should print the system's uptime using the sysinfo() function. If no
additional options are provided, print the uptime in hours, minutes, and
seconds. Add an error message if there are any issues retrieving the uptime.
4. main.c: This program will run all the executables of the above programs as
child processes using the fork-wait-exec sequence. First, create 3 child
processes using fork. Then, inside the child processes, call one of the exec
functions to execute the above programs. Each child will run one program.
The parent process will wait for all child processes to finish before returning.
5. Makefile: This makefile should build the first 3 programs (date, cal, uptime)
before building the main program. Your files should be correctly compiled
using this Makefile. The output of compiling a C file should be an executable
file of the same name. For example: date.c should be compiled to date in
Linux. [40 pts]
Rubrics:
The student should have implemented the following things:
Folder q3 containing the files date.c, cal.c, uptime.c, main.c, and
Makefile.
All files should be correctly compiled without errors using make.
In main.c, the parent process must use fork()3 times, then wait()3
times for each of the children to finish. The children should call an exec
function on ./date,./cal, and ./uptime, respectively.
Running the main executable should:
Print the current date and time in the default format using the date
program.
Display the first day of the current month calculated using Zeller's
congruence with the cal program.
Show the system's uptime using the uptime program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!