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 ; 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 ; num = n * ( n - 4 ) ; cout << num ; } int main ( ) { int n ; n = 6 ; findTriangles ( n ) ; return 0 ; }