Need help trying to figure this
I started C programming recently for classes, ive tried to program on C b4 but didnt investigate much further.
Now im learning it and I need help
This is a program that vises to calculate a quadratic equation.
The formula goes like ax^2+bx+c=0
The results are rp and rn.
What's wrong with it? Can you help me?
Thanks in advance.
Now im learning it and I need help
This is a program that vises to calculate a quadratic equation.
The formula goes like ax^2+bx+c=0
The results are rp and rn.
Code:
#include <stdio.h>
int main(void) {
float a; //Value for first variable of the equation
float b; //Value for second variable
float c; //Value for third variable
float rp; //First result of the equation, if the signal is +
float rn; //Second result of the equation, if the signal is -
printf("EQUAÇÂO QUADRATICA tipo ax^2+bx+c=0"); //Displays the formula
printf("Insira a coordenada para o a. %f /n"); //Asks for the first variable
scanf("%f", &a);
printf("Insira a coordenada para o b. %f /n"); //Second variable
scanf("%f", &b);
printf("Insira a coordenada para o c. %f /n"); //Third Variable
scanf("%f", &c);
rp=((-b)+sqrt((b*b)-(4*a*c)))/(2*a); // equation to calculate one value for x
rn=((-b)-sqrt((b*b)-(4*a*c)))/(2*a); // equation of the second value for x
printf("A variável x toma como valores: %f\n", rp ,rn) //Displays the results
return 0;
}
Thanks in advance.


![=]](/forum/images/emotions/=].gif)
