Question: Write a function that has two integer parameters and returns an integer that equals the argument that is smaller in absolute value. If the two
Write a function that has two integer parameters and returns an integer that equals the argument that is smaller in absolute value. If the two arguments have the same absolute value but different sign, the function should return the positive one. If the two arguments are identical, their (common) value should be returned. Write a main program that tests your function with enough test cases to give you confidence in the correctness of your function. Use assertions and, optionally, calls to printf. The function prototype should be
int smallerabsval(int x, int y)
Put another way, your function should at least pass these unit tests.
assert(smallerabsval(-3,2)==2); assert(smallerabsval(3,-2)==-2); assert(smallerabsval(-3,3)==3); assert(smallerabsval(5,5)==5); assert(smallerabsval(-3,-3)==-3);
language is in C
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
