ax tetuar *inputs, int m) non-empty array of inputs represented by C-string pointers and its length and returns the maximum of the double value numbers represented by the inputs - ( "0. 3", "0. 1". "1.0" : f\e", max (A, 3)): 1.000000 word is encountered, your function must print "illegal input: " to stdout, followed by the offending word, and call exit(1) nction by calling it from main so that the max of the command line arguments are printed to stdout, except for the first (which contains the program name), and O is x to fire by checking the condition in main and printing "empty input error" to stdout and returning 1 1.3 0.6 0.1 1.300000, and llegal input: x st inputs/outputs in a comment at the end of your program

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Problem 1: Option Max
In file p1.cpp implement C++ function
double max (char *inputs[), int m)
that takes a non-empty array of inputs represented by C-string pointers and its length and returns the maximum of the double value numbers represented by the inputs
E.g.,
char A[] - { "0. 3", "0. 1", "1.0" }:
printf ("%f\n", max (A, 3)):
must print 1.000000
If an illegal word is encountered, your function must print "illegal input: " to stdout, followed by the offending word, and call exit(1)
Test your function by calling it from main so that the max of the command line arguments are printed to stdout, except for the first (which contains the program name), and 0 is returned in case of success. Prevent the
assert in max to fire by checking the condition in main and printing "empty input error" to stdout and returning 1
E.g.,
/a. out 1.3 0.6 0. 1
must print 1.300000, and
/a. out 1.0 x
must print illegal input: x
List your test inputs/outputs in a comment at the end of your program
Note: Use sscanf (man sscanf) to read a double value from a C-string, much like scanf does. sscanf will succeed if the input string starts with a number, but is followed by some other string. E.g., 1.0x is a valid input. Here,
we'll ignore this issue and regard 1.0x as legal input for 1.0 and continue without printing an error message
Transcribed Image Text:Problem 1: Option Max In file p1.cpp implement C++ function double max (char *inputs[), int m) that takes a non-empty array of inputs represented by C-string pointers and its length and returns the maximum of the double value numbers represented by the inputs E.g., char A[] - { "0. 3", "0. 1", "1.0" }: printf ("%f\n", max (A, 3)): must print 1.000000 If an illegal word is encountered, your function must print "illegal input: " to stdout, followed by the offending word, and call exit(1) Test your function by calling it from main so that the max of the command line arguments are printed to stdout, except for the first (which contains the program name), and 0 is returned in case of success. Prevent the assert in max to fire by checking the condition in main and printing "empty input error" to stdout and returning 1 E.g., /a. out 1.3 0.6 0. 1 must print 1.300000, and /a. out 1.0 x must print illegal input: x List your test inputs/outputs in a comment at the end of your program Note: Use sscanf (man sscanf) to read a double value from a C-string, much like scanf does. sscanf will succeed if the input string starts with a number, but is followed by some other string. E.g., 1.0x is a valid input. Here, we'll ignore this issue and regard 1.0x as legal input for 1.0 and continue without printing an error message
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY