Program to check if the points are parallel to X axis or Y axis | CPP program to check for parallel to X and Y Axis ; To check for parallel line ; checking for parallel to X and Y axis condition ; To display the output ; Driver 's Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void parallel ( int n , int a [ ] [ 2 ] ) { bool x = true , y = true ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( a [ i ] [ 0 ] != a [ i + 1 ] [ 0 ] ) x = false ; if ( a [ i ] [ 1 ] != a [ i + 1 ] [ 1 ] ) y = false ; } if ( x ) cout << " parallel ▁ to ▁ Y ▁ Axis " << endl ; else if ( y ) cout << " parallel ▁ to ▁ X ▁ Axis " << endl ; else cout << " Not ▁ parallel ▁ to ▁ X " << " ▁ and ▁ Y ▁ Axis " << endl ; } int main ( ) { int a [ ] [ 2 ] = { { 1 , 2 } , { 1 , 4 } , { 1 , 6 } , { 1 , 0 } } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; parallel ( n , a ) ; return 0 ; }