1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72

#include "stdafx.h"
#include <math.h>
#include<stdio.h>
void reader(double *r1, double *q1, double *r2, double *q2); /*Prototype of Function responsible for taking the inputs from user*/
double length(double,double,double,double); /*Prototype of Function accountable for the calculation of length*/
double total(double,double); /*Prototype of Function to keep on adding all the perimeters together*/
void format(double,double); /*Protoype of format descryptor*/
int main(void)
{ double r1=0,r2=0; /*Declaration of First pair of Point where r1 is distance from origin and q1 is angle from an arbitary axis*/
double q1=0,q2=0; /*Declaration of second pair of Point*/
double d; /*variable which will hold the ongoing perimeter for a particular points in loop*/
double t=0; /*Initialised variable which holds the total perimeter calculated in the program*/
do {
reader(&r1,&q1,&r2,&q2); /*calling the function to get the inputs from user*/
d = length(r1,q1,r2,q2); /*Calling the function to calculate the length of side using the points given by user*/
t = total(t,d); /*Calling the function to add up the existing calculated perimeter to existing*/
format(d,t); /*Calling the function to print the values to 6 decimal places*/
} while (0 < r1 && 0 < r2 && 0 < q1 && 0 < q2);/*SENTINEL  whenever any of the number is negative the loop will finish*/
printf("INVALID INPUTS THANKS FOR USING THE PROGRAM");
}
/*FUNCTIONS*/
/*Function to Read the Polar Coordinates*/
void reader(double *r1, double *q1, double *r2, double *q2)
{
printf("Please Enter the Distance From the origin and the Angle from an arbitrary axis >");
scanf("%lf %lf",r1,q1);
printf("Please Enter the Distance From the origin and the Angle from an arbitrary axis for next point >");
scanf("%lf %lf",r2,q2);
}
/*Function to Calculate the Length of a side of Polygon*/
double length(double r1,double q1,double r2,double q2)
{
double d1,d2;
d1 = (r1*r1)+(r2*r2)(2*r1*r2)*(cos((q2q1)*(0.0175)));
d2 = sqrt(d1);
return(d2);
}
/*Function to calculate the total Perimeter of polygon*/
double total(double t,double d)
{
double a;
a = t + d;
return(a);
}
/*Function to print values format descriptor*/
void format(double d, double t)
{
printf("The length of side is %0.6f and the partially calculated perimeter is %0.6f\n\n\n",d,t);
}
