Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions

Question

Differentiate the function. r(z) = 2-8 - 21/2 r'(z) =

Answered: 1 week ago