Check if it is possible to draw a straight line with the given direction cosines | C ++ implementation of the approach ; Function that returns true if a straight line is possible ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool isPossible ( float x , float y , float z ) { float a = x * x + y * y + z * z ; if ( ceil ( a ) == 1 && floor ( a ) == 1 ) return true ; return false ; } int main ( ) { float l = 0.70710678 , m = 0.5 , n = 0.5 ; if ( isPossible ( l , m , n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }