Write a program that prompts the user for the integer coordinates of the bottom-
ID: 3633284 • Letter: W
Question
Write a program that prompts the user for the integer coordinates of the bottom-left and top-right corners of a rectangle, entered as x1 y1 x2 y2 where (x1, y1) and (x2, y2) respectively are the bottom-left and top-right corners of the rectangle. The program then asks for the coordinates of another point in the plane, entered as x3 y3, and determines whether or not this point is insidethe rectangle (including the boundaries).
example below:
Corners: -1 -1 1 1
Point: 0 0
Inside!
//program stops
another example:
Corners: -2 1 4 2
Point: 1 3
Outside
//program stops
Explanation / Answer
#include #include void enter(); void gcd(int,int); void lcm(int,int); void gcdnlcm(int,int); int main() { enter(); printf("ALL Over: :"); return 0; } void enter() { int a,b,c,d,e; char str[10]; printf("Enter the 2 numbers: "); scanf("%d %d",&a,&b); printf("Enter GCD if u want gcd of 2 numbers "); printf("else Enter LCM if u want lcm of 2 numbers "); printf("else Enter GCDNLCM if u want both lcm and gcd for the numbers: "); scanf("%s",&str); c=strcmp(str,"GCD"); d=strcmp(str,"LCM"); e=strcmp(str,"GCDNLCM"); if(c==0) gcd(a,b); else if(d==0) lcm(a,b); else if(e==0) gcdnlcm(a,b); } void gcd(int a,int b) { int c,d,r; if(a > b) { c=a; d=b; } else { c=b; d=a; } while(d !=0) { r=c%d; c=d; d=r; } printf("GCD OF 2 NUMBERS:%d ",c); } void lcm(int a,int b) { int ii,j,a1[100],b1[100]; for(ii=1;iiRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.