-
Notifications
You must be signed in to change notification settings - Fork 137
Expand file tree
/
Copy pathCheckParallel.cpp
More file actions
41 lines (36 loc) · 773 Bytes
/
CheckParallel.cpp
File metadata and controls
41 lines (36 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// CPP program to check for parallel
// to X and Y Axis
#include <bits/stdc++.h>
using namespace std;
// To check for parallel line
void parallel(int n, int a[][2])
{
bool x = true, y = true;
// checking for parallel to X and Y
// axis condition
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;
}
// To display the output
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;
}
// Driver's Code
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;
}