Re: Help. Where is my error?
- From: "Old Wolf" <oldwolf@xxxxxxxxxxxxxx>
- Date: 17 Oct 2005 14:31:46 -0700
Red Dragon wrote:
> 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);
You posted this program a couple of weeks ago and got lots
of advice. But you seem to have ignored most of this advice.
Here it is again:
1) x1, x2, R, I, S should be "double", not "float"
2) You MUST check the return value of scanf() and take appropriate
action if it is wrong
3) Don't do any casting (eg. in the line "x1 = (float)FOO")
4) The "return 0" goes AFTER the "else" block, not inside it.
Hint: If you printf the result of your scanf("%c") using
%d, you might understand what is going on.
.
- References:
- Help. Where is my error?
- From: Red Dragon
- Help. Where is my error?
- Prev by Date: Re: Windows Programming in C under DevC++
- Next by Date: Re: parse error before '=' token
- Previous by thread: Re: Help. Where is my error?
- Next by thread: Re: Help. Where is my error?
- Index(es):
Relevant Pages
|