The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 3 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
C Programming:
Write a program called perimeter.c that calculates the perimeter of a polygon.
1. Name your executable perimeter.out
2. The points of the polygon will be stored in a file and this file will be passed on
the command line arguments
3. The file itself will be a binary file containing integers
1. The first integer in the file is the number of points contained in the file
2. The remaining integers are the points, with the first integer being the x
coordinate and the second integer being the y coordinate.
3. There is an edge between each adjacent point and between the first point
and the last point
4. Each file contains at least 3 points.
4. The perimeter of a polygon is the sum of the lengths of all of its edges
5. Use a double to store your perimeter and report the perimeter to the nearest 2
decimal points.
6. MUST store your points in a struct.
7. As an aside the example tests do not form actual polygons but assume that they
do.
Example. Assume that there is a file called example.txt. It will store the following
information but in binary form. This example just gives you a visualization of
the data.
3
287 422
283 -981
781 647
./perimeter example.txt
The perimeter is 3648.30
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll