الأجوبة
/*Write a C program to test whether two lines are parallel or not. The four points are P(x1, y1), Q(x2, y2), R(x3, y3) and S(x4, y4), check PQ and RS are parallel are not*/
#include <stdio.h>
main() {
double x1, x2, y1, y2, x3, y3, x4, y4;
int i, n;
printf("Input P(x1,y1):\n");
scanf("%lf %lf", &x1, &y1);
printf("\nInput P(x2,y2):\n");
scanf("%lf %lf", &x2, &y2);
printf("\nInput P(x3,y3):\n");
scanf("%lf %lf", &x3, &y3);
printf("\nInput P(x4,y4):\n");
scanf("%lf %lf", &x4, &y4);
if ((x1 == x2) && (x3 == x4))
printf("\nPQ and RS are parallel!\n");
else if ((x1 == x2) || (x3 == x4))
printf("\nPQ and RS are not parallel!\n");
else if (((y1 - y2) / (x1 - x2) - (y3 - y4) / (x3 - x4)) == 0.0)
printf("\nPQ and RS are parallel!\n");
else
printf("\nPQ and RS are not parallel!\n");
return (0);
}
Sample Output:
Input P(x1,y1):
5
7
Input P(x2,y2):
3
6
Input P(x3,y3):
8
9
Input P(x4,y4):
5
6
PQ and RS are not parallel!
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال