Question: Requriements Program must compile with both -Wall and -Werror options enabled Submit only the files requested Use doubles to store real numbers Print all doubles
Requriements
Program must compile with both -Wall and -Werror options enabled
Submit only the files requested
Use doubles to store real numbers
Print all doubles to 2 decimal points unless stated otherwise
Restrictions
No global variables may be used
Your main function may only declare variables and call other functions
Description
Write a program called perimeter.c that find the perimeter of an arbitrary shape. Your program will be provided a binary file that contains the vertices of the shape and your program should print out the premiter of the given shape.
Additional Details
You MUST use a struct in your solution
I recommend have a Point struct
The name of the binary file will passed as a command line parameter
The binary file contains only integers
The first integer is the number of points in the file
The remaining integers are points representing the vertices of the shape
There is an edge between each adjacent point and between the last point and the first point
There are at least 3 points in each file
The perimeter of a polygon is the sum of the lengths of all of its edges
If you really look at the the points in the file you will see that they don't actually represent convex polygons but treat them like the files like they do
Examples
User input has been underlined to help you differentiate what is user input and what is program output.
Hints
If you are curious about what is in the file you can use the binaryinteger printing program we wrote in class.
Examples
In this example assume that the file example.txt contained the following values in binary. I'm displaying the file as text below to help you get an understanding of what the file looks like but remember the file is in binary with no spaces between any of the values.
Example 1
3 287 422 283 -981 781 647
./perimeter.out example.txt
The perimeter is 3648.30
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
