samedi 9 mai 2020

If OR statement isn't working, when Q or q is pressed it's supposed to exit, but it's not [closed]

This is probably an easy fix for you guys, but it's really getting to me, this piece of code isn't doing what i want it to do. input it P x y, if Q or q is pressed then it exits, else it displays the coords, but its not working, suggestions please guys!

#include <stdio.h>

int main()
{
float x, y;
char input;


scanf("c", &input);

if (input == 'Q' || input == 'q')
{
  printf("terminating program");
  return(0);
}
else
{
scanf(" %c %f%f", &input, &x, &y);
printf("coordinates for %c are %f %f", input, x, y);
}
return(0);
}

Aucun commentaire:

Enregistrer un commentaire