15-17
15. Write a C program getSalads to read from stdin as many lines of input as possible (each line can be assumed to be a nonnegative integer). Do not program it in a way that would force the user to type a special number of indicate the end of inputs. The program should print the square roots of all input numbers (one per line). You can decide whether you want to print these square roots after all the input numbers have been received, or you want to print a square root as each input number is received. A sample run can look like the following (note that number of input integers and the integers themselves can be arbitrary): $ ./getSalad enter some nonnegative integers: 1 The square root of 1 is 1.000000 2. The square root of 2 is 1.414214 3 The square root of 3 is 1.732051 5 The square root of 5 is 2.236068 16. Suppose you have written your previous C program getsalad.c and it works fine as long as each input number is nonnegative. But you know your program might behave unexpectedly if any input number is negative. How would you modify your code so that it will abort and report the unfortunate situation when a negative number is input? 17. Suppose you have written a C program getBread.c and it reads from stdin as many lines of input as possible (each line can be assumed to be a nonnegative integer). Similar to the behavior of the previous program getSalads, the program should compute and print the values of some function of all input numbers (one per line). The math function fis much more complicated than the square root function and you want to test your own implementation of this function in the program on a selected set of 50 Input Integers and see whether it produces the correct outputs. The program may have bugs and you may need to revise the code and test it many times on those 50 integers. What would you do, other than hard-coding the 50 integers into your program source code, to avoid re- typing the 50 input integers each time you want to test your code after revising and re-compiling it