Number of triangles in a plane if no more than two points are collinear | C ++ program to find the number of triangles in a plane if no more then two points are collinear . ; Function to find number of triangles in a plane . ; Formula to find number of triangles nC3 = n * ( n - 1 ) * ( n - 2 ) / 6 ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int countNumberOfTriangles ( int n ) { return n * ( n - 1 ) * ( n - 2 ) / 6 ; } int main ( ) { int n = 4 ; cout << countNumberOfTriangles ( n ) ; return 0 ; }