Assignment #3 Solution




• Answer the questions individually. Group effort is not allowed.

• Solutions must be committed to your respective repositories on github.

• Ensure that your code runs on

• Prototypes must be provided for all functions within the header file define.h. Definitions for all functions must be in impl.c

• You may use main.c for your own testing. If you use output to standard output or standard error for debugging, ensure it is suppressed or removed by the time you submit.

• Do complete the all and main rules in Makefile. Do not modify or remove the test, test-run, or really-clean rules in Makefile.

• Code must be appropriately commented.

• Useful resources:

Common Linux Commands


1. Within a file define.h define a structure “point” that contains a point in space with x, y and z coordinates as floating point numbers. In a file impl.c, implement a function float distance(struct point p1, struct point p2) that returns the euclidean distance between points p1 and p2. (30 points)

2. In impl.c write a function int strrindex(char s[], char t[]), which returns the position of the rightmost occurrence of t in s, or -1 if there is none. (40 points)

3.Inimpl.cwriteafunctionintisint(charstr[])thatacceptsacharac- terarrayandreturns1ifthecharacterarrayrepresents avalidinteger,0other- wise.Avalidintegeriswithanoptionalnegative’-’characterfollowedby1or morecharactersbetween0-9inclusive.(30points)