Number of triangles formed by joining vertices of n | C ++ program to implement the above problem ; Function to find the number of triangles ; print the number of triangles having two side common ; print the number of triangles having no side common ; Driver code ; initialize the number of sides of a polygon
#include <bits/stdc++.h> NEW_LINE using namespace std ; void findTriangles ( int n ) { int num = n ; cout << num << " ▁ " ; cout << num * ( num - 4 ) * ( num - 5 ) / 6 ; } int main ( ) { int n ; n = 6 ; findTriangles ( n ) ; return 0 ; }