Question: C programming question Here is the question and then I'll put my code to check what is the error Problem B: Write a function that
C programming question
Here is the question and then I'll put my code to check what is the error
Problem B: 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 mainprogram 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);
#include
int abs(int x);
int smallerabsval( int x, int y){ x = 3 , y = -5 } { if(x==y) return x; int absx = abs(x); int absy=abs(y); if(absx > abs y) return y; else if(absy
return absx;}
int main(){ int err = smallerabdval(absx, absy) assert(absx==3 && absy==5 ); int err = smallerabsval(absx, absy) }

emacs24@vm-for-1310 File Edit Options Burters Tools C Help Undo include assert.h nt absiint x); int staller absval abs y) retum y else if (absy absx) retum x; return absx int ain nt errsnallerabdval (absx, absy) assert(ahsx_3kh ahsy=5 ); Conpilation started at Thu Fch 1 17:59 42 gcc -Nall -Wextra go smallerabsva snallerabsva.c snallerabsva.C: In tunction smallerabsva snauerabsya, di 8:7 i error: "X redeclared as different kind of symbol int x-3 int y--5 smallerabaya.ciwa.mule : previous definition of "X"was here int smaller ebsveu in1 , int y){ srallerabsva.c:B:1a: er: expected identifier or 'befre 'int' corpilation Conpilation:exit programmer dr...-Execute File 18:08 Right Ctrl
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
