/***********************************************************
angle-measure.ch
Polygons
This program calculates the number of interior angles,
diagonals, measure of each angle and the perimeter
of the entire polygon based on the number of sides and
the length of each side.
************************************************************
Copyright 2014 SoftIntegration Inc.
http://www.softintegration.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
***********************************************************/
//Geometry: some polygon formulas
//Intialize variables
int sides, num_diags;
double sum_of_angles, regular_angle;
//Get number of sides
printf("how many sides in your polygon? ");
scanf("%d", &sides);
//Calculate and display the sum of the angles
sum_of_angles = (sides - 2) * 180;
printf ("\nsum of interior angles: %lf\n", sum_of_angles);
//Calculate and display the number of diagonals
num_diags = (sides*(sides - 3))/2;
printf("\nnumber of diagonals: %d\n", num_diags);
//Calculate and display the angle and perimeter
regular_angle = sum_of_angles / sides;
printf("\nif it's a regular %d-gon then each angle is %lf\n", sides, regular_angle);
printf("\nif it's regular and one side is of length x, then the perimeter is %d * x", sides);