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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started