text: Find number of diagonals in n sided convex polygon | C ++ function to find number of diagonals in n sided convex polygon ; driver code to test above function
code: #include <iostream> NEW_LINE using namespace std ; int numberOfDiagonals ( int n ) { return n * ( n - 3 ) / 2 ; } int main ( ) { int n = 5 ; cout << n << " ▁ sided ▁ convex ▁ polygon ▁ have ▁ " ; cout << numberOfDiagonals ( n ) << " ▁ diagonals " ; return 0 ; }