Help. Where is my error?



I am self study C student.  I got stuck in the program below on quadratic equation and will be most grateful if someone could help me to unravel the mystery.
Why does the computer refuse to  execute my  scanf ("%c",&q);
On input 3  4  1 (for a,b and c)   I  had real roots  OK
On input 1  8  16   I had  same real roots OK.
 
However on 4  2  5, (for imaginary roots )  the computer cannot see the scanf ("%c",&q);  statement.  It just jumps over it.
How can I make the computer not to ignore this statement?  I am on Visual C++ platform.
Thanks
Khoon.
 
/*   Roots of a Quadratic Equation.
      12.10.05  */
 
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
int main (void)
 
{
 int a; int b; int c; float x1; float x2; int E; int E1; float R; float I;float S;
 char p; char q; char y;
 
 printf ("Please key in the value of constant a,b and c for finding the roots of quadratic");
    printf ("equation ax%c+bx+c=0  :",253);
 scanf ("%d%d%d", &a,&b,&c);
   
    E  =(b*b)-(4*a*c);
 
   if ( E > 0)
   {    
    x1 = (float)(-b+sqrt(E))/(2*a);
    x2 = (float)(-b-sqrt(E))/(2*a);
 
  printf ("\nYour quadratic equation has two distinct real roots: x1=%1.6f ,x2=%1.6f",x1,x2);
   }
  
 

   else if (E == 0)
   {
 
      x1 = (float)(-b+sqrt(E))/(2*a);
      
   printf ("\nYour quadratic equation has two same: x1=x2=%1.6f\n",x1);
   }
 
   else
   {
 
     p = 'y';
 
  printf ("Your quadratic equation has two distinct imaginary roots.  Do you want to know\n");
  printf ("the values of the imaginary roots (Y/N)?");
   
  scanf ("%c",&q);
 
  printf ("\nq = %c\n",q);/* Test statement*/
 
  if (p==q)
   printf ("OK I will show your the imaginary roots tomorrow.\n");
 
  else
   printf ("Good bye\n");
 
  return 0;
 
   }
}
 


Relevant Pages

  • Re: A dead subject
    ... > more like Spock, control your emotions. ... roots with the equation in any number of forms. ... all use the standard form exclusively and we don't always ...
    (sci.math)
  • Re: Ummm... Whats a "-0" in Spinlandia?
    ... it can only have 2 roots. ... You deny that quadratic have 2 roots? ... and yes this is a quadratic equation. ... "it aint what you know that gets you in trouble ...
    (talk.origins)
  • Finding roots of a complex equaitions
    ... Prove that the usual formula solves the quadratic equation ... where the coefficients a,b,c are complex numbers. ... Lastly the answers to roots were given as ...
    (sci.math)
  • Re: Roots of AX^2 + BX + C
    ... quadratic equation to be complex. ... roots will be complex if is less than zero. ... The probability of hitting any finite interval would have to be 0, ...
    (sci.math)
  • Re: Finding set of possible values of a given function
    ... looks like a hilltop. ... and exit wounds so commonly mentioned in forensic television dramas). ... At the grazing point we want the two roots to coalesce into one. ... would be the case where the quadratic equation has just one root, ...
    (sci.math)