Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For the following programs, you should run each of them using Dev-C++. You answe

ID: 3849483 • Letter: F

Question

For the following programs, you should run each of them using Dev-C++. You answer should include screen shots of your code and program outputs. Your programs should be properly commented. Problem 1 . Use C NOT C++.

Please includ the answer as a Text, so I can copy and paste it to test it.

Problem 3 Write a program that takes the x-y coordinates of a point in the Cartesian plane and prints a message telling either an axis on which the point lies or the quadrant in which it is found. QII QI QIV Qlll Sample lines of output: (-1.0, 2.5) is in quadrant III (0.0, 4.8) is on the y-axis

Explanation / Answer

#include <stdio.h>
#include <math.h>

struct Point //structure
{
float x;
float y;
};


int quadrant(struct Point p) //quadrant function to determine the
quadrant in which point lies
{
if( p.x>0 && p.y>0)
return 1;
else if(p.x<0 && p.y>0)
return 2;
else if(p.x<0 && p.y<0)
return 3;
else if(p.x>0 && p.y<0)
return 4;
else
return 0;

}

int axis(struct Point p) //axis function to determine on which axis point lies
{
if(p.x == 0)
return 1;
else if(p.y == 0)
return 2;
else
return 0;

}

int main()
{
struct Point p1 = {-1.0, -2.5};
struct Point p2 = {0.0, 4.8};

printf("(%.1f,%.1f) is in quadrant %d",p1.x,p1.y,quadrant(p1));

printf(" ");
if(axis(p2) == 1)
printf("(%.1f,%.1f) is on y axis",p2.x,p2.y,axis(p2));
else if(axis(p2) == 2)
printf("(%.1f,%.1f) is on x axis",p2.x,p2.y,axis(p2));

else
printf(" ");

return 0;
}


Output:

(-1.0, -2.5) is in quadrant 3

(0.0, 4.8) is on the y-axis

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote