1
#include <stdio.h>
#include <stdlib.h>
int main()
{
float x,y;
char k;
do{
printf("Este Programa indica o quadrante no plano cartesiano\n");
printf("Entre com o valor de x:");
scanf("%f",&x);
printf("Entre com o valor de y:");
scanf("%f",&y);
if((x>0)&&(y>0))
printf("O Ponto P(%.2f,%.2f) pertence ao primeiro Quadrante\n",x,y);
else
{
if((x<0)&&(y>0))
printf("O Ponto P(%.2f.%.2f) pertence ao segundo Quadrante\n",x,y);
else
{
if((x<0)&&(y<0))
printf("O Ponto P(%.2f,%.2f) pertence ao terceiro Quadrante\n",x,y);
else
{
if((x>0)&&(y<0))
printf("O Ponto P(%.2f,%.2f) pertence ao quarto Quadrante\n",x,y);
else
{
if((x==0)&&((y>0||y<0)))
printf("O Ponto P(%.2f,%.2f) esta no eixo y\n",x,y);
else
{
if((y==0)&&((x>0||x<0)))
printf("O Ponto P(%.2f,%.2f) esta no eixo x\n",x,y);
else
{
if((x==0)&&(y==0))
printf("O Ponto P(%.2f,%.2f) esta na origem\n\n",x,y);
fflush(stdin);
printf("\nDeseja digitar outro ponto. (S)/(N):\n");
scanf("%c",&k);
}while((k=='S')||(k=='s'));
system("Pause");
I would like to implement in this code a counter and then write the points totals in each of the situations. For example, "Total points on the x-axis: ". However, I’m not getting it for some reason. If anyone can give a hint, thank you.
float
vsdouble
: prefers at all timesdouble
when you have to work with floating point numbers. (Exceptions to this rule are very few.)– pmg
How do you use
system("Pause")
Knowing that you are using Windows. On all other current Operating Systems the functionfflush(stdin)
has Undefined Behavior. If you can write your code using another way to get those features (system("Pause")
andfflush(stdin)
), make that same code more portable.– pmg