Compile and Run
1 // You can print the values to stdout for debugging
using namespace std;
int isTriangle(Point *P1, Point *P2, Point *P3)
Д |
5
6
// write your code here
a
Answers
I didn't understand your question
Program is given below.
Explanation:
//Header files
#include <stdio.h>
#include <stdlib.h>
struct Point{
int x;
int y;
};
//Defining function
int isTriangle(Point*p1, Point*p2, Point*p3)
{
int c;
//Checking for collinearity
c = ((p2->x - p1->x)*(p3->y - p1->y))
!= ((p2->y - p1->y)*(p3->x - p1->x));
printf("%d",c);
return c;
}
int main(){
struct Point a1;
struct Point a2;
struct Point a3;
//Values of Point 1
a1.x=3;
a1.y=4;
//Values of Point 2
a2.x=2;
a2.y=1;
//Values of Point 3
a3.x=1;
a3.y=5;
//Calling the defined function
isTriangle(&a1, &a2, &a3);
}
Refer the attached image for the output.