Question: Preliminary Material We are not far enough into C to do more interesting things ( pointers and such are yet to come but are coming

Preliminary Material
We are not far enough into C to do more interesting things (pointers and such are yet to come but are coming soon), yet an important topic can be addressed now: command line arguments.
What is a command line argument? You have already used them in completing programs 0 and 1. In program 0, when you typed gcc helloworld.c to compile your source file, both gcc and helloworld.c were command line arguments. Likewise for program 1, in gcc p0.c both the gcc and p0.c were command line arguments. Command line arguments are the textual material in the command that initiates execution of the program in the system.
In both C and C++, there are actually two arguments to the main() function that are generally left out if the program does not examine command line arguments. Here is how they are declared when they are used.
int main(int argc, char* argv[])
The meaning of these arguments is as follows.
int argc the number of command line arguments passed by the OS to the program.
char* argv[] argv is an array of char pointers, each to a command line argument.
(By convention, these names are always used for C and C++ main()s formal parameters.)
Remember, array indices in C start with 0. This is zero-based indexing. The C string pointed to by argv[0] is either the name of the program invoked or the full path, including name, of the program invoked. Thus, argc will always have a value of at least 1.
Assignment
Write a program named clt.c that accepts four command line arguments in addition to the argv[0] program name/path and produces an output to the console as follows.
Your program will accept four command line arguments (indices 1 to 4) in the following order and with the following meanings, then output to console a table of temperatures in degrees Fahrenheit, Celsius and Kelvin.
A single ASCII character that must be an c,C,f,F,k or K.
A c or C indicates conversion from Celsius to Fahrenheit and Kelvin,
an f or F from Fahrenheit to Celsius and Kelvin, and
a k or K from Kelvin to the other two.
An integer value indicating the starting temperature in the scale specified.
An integer value indicating the temperature not to be exceeded.
A floating-point value indicating the step between values (2 and 3) in the scale specified.
Print a header line as follows.
Celsius Fahrenheit Kelvin
Starting with the temperature indicated by argv[2], in the scale specified by argv[1], calculate the equivalent temperatures in the other two scale, then print the values to the stdout (console output). The overall format should be as follows.
Celsius Fahrenheit Kelvin
####.## ####.## ####.##
Values are to be right-justified with two decimal digits.
Increment the temperature in the scale from argv[1] by the value from argv[4] and repeat the process until the upper bound in argv[3] is reached. Print the values if the argv[3] value is matched, but not if exceeded.
Your submission must compile without errors using the gcc compiler on csx and the program must run correctly on csx.
Submission to csx will use the following command on csx.
handin cs2433-rlchurc program2 clt.c
Please note that the Linux operating system and both C and C++ are case sensitive.
To assist in matching alignments to those above, the following indicates columns.
0123456789012345678901234567890123456789
Celsius Fahrenheit Kelvin
####.## ####.## ####.##

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!