Question: Write a C program called pythag.c that takes two command line arguments, which represent the length of two sides of a right triangle a and

Write a C program called pythag.c that takes two command line arguments, which represent the length of two sides of a right triangle a and b respectively. These arguments will be character strings, so you should use the atof function in stdlib.h to convert the character strings into double precision floating-point numbers. If your program is called with less than, or more than, two command line arguments, it should print an error message that specifies what arguments you expect, and return a return code that indicates that the program failed. Your program should then calculate the length of the hypotenuse, c. You may use C library functions EXCEPT those in the math.h library. (This includes built-in functions like sqrt, pow, or logarithm and exponential functions.) Hint: Look at the web, such as Wikipedia Square Root Computation to get some ideas on how to compute the value for c without math.h library functions. Do not copy C code from the web! Write your own code from the ideas on the web. Your calculation should compute the value of c accurately to at least 6 decimal places. In other words, you answer should be the correct value for c +/- 0.000001. Finally, your program should print out the values of a, b, and c, using the printf statement: printf("a=%f, b=%f, c=%f ",a,b,c); and then return a return code that indicates that the program worked.

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 Databases Questions!