Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am currently trying to create a program in C that: First, get your filter to print all of the input numbers in a single

I am currently trying to create a program in C that:

First, get your filter to print all of the input numbers in a single column with their decimal points lined up (and all 13 digits of precision).

Second, create three columns of output (with the decimal points lined up). Be sure to take into consideration that the last row need not have three columns.

Third, have a command line argument determine the number of columns.

Fourth, have the environment variable determine the number of columns.

Fifth, let a command line argument or an environment variable determine the precision of the output numbers.

Last, check for the configuration file (before checking for the environment variables and the command-line arguments) and, if it exits, have its values override the default values

So far I have this, but I'm having difficulties creating multiple columns:

Here is my code:

image text in transcribed

here is my output:

image text in transcribed

int main(int argc, char *argv[]) { // Set the default value. int incBy - @j FILE * // Override the default value with a value from the configuration file. fp; if ( (fp = fopen("incrementor.cfg", "r")) != NULL ) { // get an operand from the configuration file fscanf(fp,"%d", &incy); } = // Override the default value with an environment variable value. char * op; if ( (op = getenv( "GET_COLUMNS" )) != NULL ) { 11 get an operand from the environment incBy atoi(op); } /*char op; if ( (op = getenv( "Incrementorvalue" ) != NULL) { 11 get an operand from the environment incBy atoi(op); // Get a command line argument (if it exists). if (argc > 1) { // get an operand from the command line incBy atoi(argv[1]); } // Process the stream of input numbers. double x; while( scanf("%1f", &x ) != EOF ) { | printf("%18.13F%2d%18.13 ", (x + incy)); } return; } 8795.5735953856019 4359.4382152775661 1789.0545976134526 3822.7270119327372 3839.4223456526383 4947.1509750663781 844.0257576219977 6021.4889370403152 67.6124149296548 1.2859889522988 5901.4852748191779 4824.1472212897124 4664.1423383281963 4480.4419080172129 8666.2644734031182 3974.1212805566574 5070.7650990325628 8971.5789666432684 4321.7422406689657 2884.6983855708486 5112.1560106204415 6528.1992248298593 int main(int argc, char *argv[]) { // Set the default value. int incBy - @j FILE * // Override the default value with a value from the configuration file. fp; if ( (fp = fopen("incrementor.cfg", "r")) != NULL ) { // get an operand from the configuration file fscanf(fp,"%d", &incy); } = // Override the default value with an environment variable value. char * op; if ( (op = getenv( "GET_COLUMNS" )) != NULL ) { 11 get an operand from the environment incBy atoi(op); } /*char op; if ( (op = getenv( "Incrementorvalue" ) != NULL) { 11 get an operand from the environment incBy atoi(op); // Get a command line argument (if it exists). if (argc > 1) { // get an operand from the command line incBy atoi(argv[1]); } // Process the stream of input numbers. double x; while( scanf("%1f", &x ) != EOF ) { | printf("%18.13F%2d%18.13 ", (x + incy)); } return; } 8795.5735953856019 4359.4382152775661 1789.0545976134526 3822.7270119327372 3839.4223456526383 4947.1509750663781 844.0257576219977 6021.4889370403152 67.6124149296548 1.2859889522988 5901.4852748191779 4824.1472212897124 4664.1423383281963 4480.4419080172129 8666.2644734031182 3974.1212805566574 5070.7650990325628 8971.5789666432684 4321.7422406689657 2884.6983855708486 5112.1560106204415 6528.1992248298593

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions