Starting from:

$30

Assignment 3 Within a file define.h

Assignment 3
Instructions
• Answer the questions individually. Group effort is not allowed.
• Ensure that your code runs on remote.cs.binghamton.edu.
• 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
– http://c-faq.com/
– https://cdecl.org
Questions
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)
1
3. In impl.c write a function int is int(char str[]) that accepts a character array and returns 1 if the character array represents a valid integer, 0 otherwise. A valid integer is with an optional negative ’-’ character followed by 1 or
more characters between 0-9 inclusive. (30 points)
2

More products