Given that all the angles of a quadrilateral are in AP having common difference ‘d’, the task is to find all the angles.

**Examples:**

Input: d = 10 Output: 75, 85, 95, 105 Input: d = 20 Output: 60, 80, 100, 120

**Approach:**

We know that the angles of the quadrilateral are in AP and having the common difference ‘d’.

So, if we assume the first angle to be ‘a’ then the other angles can be calculated as,

‘a+d’, ‘a+2d’ and ‘a+3d’

And, from the properties of quadrilaterals, the sum of all the angles of a quadrilateral is 360. So,

(a) + (a + d) + (a + 2*d) + (a + 3*d) = 360

4*a + 6*d = 360

a = (360 – (6*d)) / 4

where ‘a’ is the angle assumed in the beginning and ‘d’ is the common difference.

Below is the implementation of the above approach:

## C++

`// C++ implementation of the approach ` `#include <bits/stdc++.h> ` `#define ll long long int ` `using` `namespace` `std; ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `int` `d = 10; ` ` ` `double` `a; ` ` ` ` ` `// according to formula derived above ` ` ` `a = (` `double` `)(360 - (6 * d)) / 4; ` ` ` ` ` `// print all the angles ` ` ` `cout << a << ` `", "` `<< a + d << ` `", "` `<< a + (2 * d) ` ` ` `<< ` `", "` `<< a + (3 * d) << endl; ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// java implementation of the approach ` ` ` `import` `java.io.*; ` ` ` `class` `GFG { ` ` ` `// Driver code ` ` ` ` ` `public` `static` `void` `main (String[] args) { ` ` ` `int` `d = ` `10` `; ` ` ` `double` `a; ` ` ` ` ` `// according to formula derived above ` ` ` `a = (` `double` `)(` `360` `- (` `6` `* d)) / ` `4` `; ` ` ` ` ` `// print all the angles ` ` ` `System.out.print( a + ` `", "` `+ (a + d) + ` `", "` `+ (a + (` `2` `* d)) ` ` ` `+ ` `", "` `+ (a + (` `3` `* d))); ` ` ` `} ` `} ` `//This code is contributed ` `//by inder_verma ` |

*chevron_right*

*filter_none*

## Python

`# Python implementation ` `# of the approach ` `d ` `=` `10` `a ` `=` `0.0` ` ` `# according to formula ` `# derived above ` `a` `=` `(` `360` `-` `(` `6` `*` `d)) ` `/` `4` ` ` `# print all the angles ` `print` `(a,` `","` `, a ` `+` `d, ` `","` `, a ` `+` `2` `*` `d, ` ` ` `","` `, a ` `+` `3` `*` `d, sep ` `=` `' '` `) ` ` ` `# This code is contributed ` `# by sahilshelangia ` |

*chevron_right*

*filter_none*

## C#

`// C# implementation of the approach ` `using` `System; ` ` ` `class` `GFG ` `{ ` ` ` `// Driver code ` `public` `static` `void` `Main () ` `{ ` ` ` `int` `d = 10; ` ` ` `double` `a; ` ` ` ` ` `// according to formula derived above ` ` ` `a = (` `double` `)(360 - (6 * d)) / 4; ` ` ` ` ` `// print all the angles ` ` ` `Console.WriteLine( a + ` `", "` `+ (a + d) + ` ` ` `", "` `+ (a + (2 * d)) + ` ` ` `", "` `+ (a + (3 * d))); ` `} ` `} ` ` ` `// This code is contributed ` `// by anuj_67 ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP implementation of the approach ` ` ` `// Driver code ` `$d` `= 10; ` ` ` `// according to formula ` `// derived above ` `$a` `= (360 - (6 * ` `$d` `)) / 4 ; ` ` ` `// print all the angles ` `echo` `$a` `, ` `", "` `, ` `$a` `+ ` `$d` `, ` `", "` `, ` ` ` `$a` `+ (2 * ` `$d` `), ` `", "` `, ` `$a` `+ (3 * ` `$d` `); ` ` ` `// This code is contributed ` `// by ANKITRAI1 ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

75, 85, 95, 105

## Recommended Posts:

- Check whether Quadrilateral is valid or not if angles are given
- Program to find smallest difference of angles of two parts of a given circle
- Find the area of quadrilateral when diagonal and the perpendiculars to it from opposite vertices are given
- Maximum area of quadrilateral
- Exterior angle of a cyclic quadrilateral when the opposite interior angle is given
- Number of quadrilateral formed with N distinct points on circumference of Circle
- Length of Diagonals of a Cyclic Quadrilateral using the length of Sides.
- Circumradius of a Cyclic Quadrilateral using the length of Sides
- Find all angles of a given triangle
- Find all angles of a triangle in 3D
- Find other two sides and angles of a right angle triangle
- Count of obtuse angles in a circle with 'k' equidistant points between 2 given points
- Check if a triangle of positive area is possible with the given angles
- Check whether the triangle is valid or not if angles are given
- Sum of internal angles of a Polygon
- Length of remaining two sides of a Triangle from a given side and its adjacent angles
- Check if an N-sided Polygon is possible from N given angles
- Program to find whether a no is power of two
- Program to find parity
- Program to find amount of water in a given glass

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.