Multiple errors in a string in your code. Let's go one by one:
if (a = 0)
Here you are assigning zero to a
, then checking if this value is true (zero is false). Soon you overwrite the original value of a
and the conditional value will always be false. To compare equality use ==
:
if (a == 0)
if (a == 0);
The conditional expects to receive a meal after it. You intended to run printf ("Nao e uma equação do 2 grau\n");
, but put ;
there. That alone is an empty command. If a
is zero, do nothing. Here you caused the problem with else
, after all, since there are no keys { ... }
in the conditional it can only receive a command, and you have two then. The second ( printf
) is out of conditional. When it arrives in else
you have already left the parole and it does not know what to do.
delta = b^2 - 4*a*c
First of all, there was a semicolon at the end. And most importantly,% w / w is not power . This operator makes bitwise xor . For power you can use ^
. The function comes from pow(b, 2)
. Or much better: #include <math.h>
.
b*b
There were no relatives! It should be if delta < 0
.
if (delta < 0)
Where does the raiz = sqrt(delta);
function come from? You should include sqrt
to make it work.
#include <math.h>
printf ("O valor de X1 e X2 são: ", x1, x2);
will not count the values for you. It also does not know how to detect the types of values you want to deal with. Use this:
printf ("O valor de X1 e X2 são: %g e %g", x1, x2);
Return
You have declared a printf
function. It returns int main()
, but you did not return int
! Its function is returning unspecified value, which can be problematic. Add at the end: int
. Traidically zero indicates no error occurred. You can use one for error. Or any other value of your choice.
Arguments
The function return 0;
takes any number of arguments of any kind. This is illegal for the int main()
function. It should either: get zero arguments, or get a main
and a int
. Set it like this to zero arguments:
int main(void)
char**
Only ASCII characters in C code are allowed. You have used things like stray '6' in program
or ç
. It is also likely that you have entered some invisible (nonprintable) character in the middle of the code, confusing the compiler.
As you can see, there was a lot wrong with such a small block. Most of this is pure lack of attention to the syntax of C. I suggest a more detailed study of how it works.