bsc

Comprehensive codebase and coursework for the 4-year B.Sc. Computer Science Honours degree (WBSU)

git clone https://github.com/notamitgamer/bsc.git
· rebuilt hourlyOpen on GitHub
root / semester_1 / letusc / luc017.c

luc017.c (734B)


      1 /* Given a point (x, y), write a program to find out if it lies on X-axis, Y-axis or origin. */
      2 /* Let Us C, Chap- 3, Page - 53, Qn No.: f(h) */
      3 
      4 #include <stdio.h>
      5 #include <math.h>
      6 #define EPSILON 0.00001
      7 
      8 int main()
      9 {
     10     double x, y;
     11     printf("Enter the point P(x, y) : ");
     12     scanf("%lf %lf", &x, &y);
     13     if (fabs(x) < EPSILON && fabs(y) < EPSILON)
     14         printf("\nPoint P(%g, %g) lies on the origin.", x, y);
     15     else if (fabs(x) < EPSILON)
     16         printf("\nPoint P(%g, %g) lies on the Y-Axis.", x, y);
     17     else if (fabs(y) < EPSILON)
     18         printf("\nPoint P(%G, %g) lies on the X-Axis.", x, y);
     19     else
     20         printf("\nThe point P(%g, %g) lies in a QUADRANT (not on an axis or the origin).", x, y);
     21     return 0;
     22 }