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 q which should contain the following files:
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 optionsflags to specify the desired format egu for UTC, r
for RFC format If no flag is passed, it should print the default date and
time format.
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.
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.
main.c: This program will run all the executables of the above programs as
child processes using the forkwaitexec sequence. First, create 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.
Makefile: This makefile should build the first 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. pts
Rubrics:
The student should have implemented the following things:
Folder q 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 times, then wait
times for each of the children to finish. The children should call an exec
function on datecal 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
