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 and In program when you typed gcc helloworld.c to compile your source file, both gcc and helloworldc were command line arguments. Likewise for program in gcc pc both the gcc and pc 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 mainint 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 mains formal parameters.
Remember, array indices in C start with This is zerobased indexing. The C string pointed to by argv 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
Assignment
Write a program named cltc that accepts four command line arguments in addition to the argv program namepath and produces an output to the console as follows.
Your program will accept four command line arguments indices to 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 cCfFk 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 floatingpoint value indicating the step between values and in the scale specified.
Print a header line as follows.
Celsius Fahrenheit Kelvin
Starting with the temperature indicated by argv in the scale specified by argv 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 rightjustified with two decimal digits.
Increment the temperature in the scale from argv by the value from argv and repeat the process until the upper bound in argv is reached. Print the values if the argv 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 csrlchurc program cltc
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.
Celsius Fahrenheit Kelvin
###### ###### ######
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
