# Geeksforgeeks Solution For " Parallel or Perpendicular? "

GeeksforGeeks Solution For School Domain .Below You Can Find The Solution Of Basic ,Easy ,Medium ,Hard .You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers

Problem :- Given two force vectors, find out whether they are parallel, perpendicular or neither. Let the first vector be A = a1 i +a2 j + a3 k and the second vector be B = b1 i + b2 j + b3 k.

A.B = a1*b1 + a2*b2 + a3*b3

A x B = (a2*b3 - a3*b2) i - (a1*b3 - b1*a3) j + (a1*b2 - a2*b1) k

|A|^2 = a1^2 + a2^2 + a3^2

If A.B = 0, then A and B are perpendicular.

If |A X B|^2 = 0, then A and B are parallel.

Solution :-

#include <iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int a1=0,a2=0,a3=0,b1=0,b2=0,b3=0,par,per;
cin>>a1>>a2>>a3>>b1>>b2>>b3;
par=(a2*b3-a3*b2)-(a1*b3-b1*a3)+(a1*b2-a2*b1);
per= a1*b1 + a2*b2 + a3*b3;
if(par==0)
cout<<"1\n";
else if(per==0)
cout<<"2\n";
else
cout<<"0\n";
}
return 0;

}

Output:-