Thursday, 11 February 2016

program to check if all the three points fall on one straight line


Given three points (x1, y1), (x2, y2) and (x3, y3) , write a program to check if all the three points fall on one straight line.

SOLUTION:

#include<stdio.h> int main() { int x1, x2, x3, y1, y2, y3; scanf("%d %d %d %d %d %d", &x1,&y1,&x2,&y2,&x3,&y3); float area; area=0.5*((x1*(y2-y3))+(x2*(y3-y1))+(x3*(y1-y2))); if(area==0) { printf("Yes"); } else { printf("No"); } return(0); }

No comments:

Post a Comment