Wednesday, March 18, 2020

  • Session

    Input & Ouput
  • Question ID

    1111210046 : Find QuadrantCoordinate Point in a XY Coordinate System
  • Problem Description

    Read a coordinate point in a XY coordinate system and determine its quadrant. The program accepts X and Y. Depending on the value of X and Y we need to determine on which quadrant this point lies.If both x y are equal to zero it is in origin.

    Both are negative it is in third quadrant. If both are positive it is in first quadrant.

    If x is greater than 0 and y is less than 0 it is in second quadrant. If x is less than 0 and y is greater than 0 it is in fourth quadrant.

    1st = First quadrant
    2nd = Second quadrant
    3rd = Third quadrant
    4th = Fourth quadrant
  • Logic Test Case 1

    Input (stdin)
    20 30
    
    
    Expected Output
    point(20,30)lies in the First quadrant
  • Logic Test Case 2

    Input (stdin)
    -30 -60
    
    
    Expected Output
    point(-30,-60)lies in the Third quadrant



 #include <stdio.h>
int main () 
 int co1=20,co2=30;
  scanf ("%d%d",&co1,&co2);
  if (co1>0&&co2>0)
    printf ("point(%d,%d)lies in the First quadrant\n",co1,co2);
  else if (co1<0&&co2>0)
    printf ("point(%d,%d)lies in the Second quadrant\n",co1,co2);
  else if (co1<0&&co2<0)
    printf ("point(%d,%d)lies in the Third quadrant\n",co1,co2);
  else if (co1>0&&co2<0)
    printf ("point(%d,%d)lies in the Fourth quadrant\n",co1,co2);
  return 0;
}



No comments:

Post a Comment

cisco Cybersecurity Essentials Quiz 8 answer in bold

Question  1 Correct Mark 2.00 out of 2.00 Flag question Question text A company has had several incidents involving users downloading unauth...