Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Calculator for Quadratic Equations
SUBMITTED BY:
uuuuuu
DATE:
Oct. 24, 2016, 7:11 p.m.
FORMAT:
Text only
SIZE:
1.1 kB
Raw
Download
Tweet
HITS:
625
Go to comments
Report
#include <stdio.h>
#include <conio.h>
#include <math.h>
int main()
{
printf("Calculator for Quadratic Equations.Please enter values for a, b and c. \n");
float a, b, c;
float x1, x2, d;
printf("Enter a = ");
scanf("%g", &a);
printf("Enter b = ");
scanf("%g", &b);
printf("Enter c = ");
scanf("%g", &c);
if (a == 0)
{
x1 = - c / b;
printf("x1 = %g\n", x1);
}
else if (b == 0)
{
if (-c / a < 0)
{
printf("Nqma reshenie\n");
}
else
{
x1 = sqrt(-c / a);
x2 = -1 * sqrt(-c / a);
printf("x1 = %g\n", x1);
printf("x2 = %g\n", x2);
}
}
else if (c == 0)
{
x1 = 0;
x2 = -b / a;
printf("x1 = %g\n", x1);
printf("x2 = %g\n", x2);
}
else
{
d = b*b - 4 * a*c;
if (d < 0)
{
printf("Nqma realni koreni\n");
}
else if (d == 0)
{
x1 = (-b) / (2 * a);
printf("x1 = x2 = %g\n", x1);
}
else
{
x1 = (-b + sqrt(d)) / (2 * a);
x2 = (-b - sqrt(d)) / (2 * a);
printf("x1 = %g\n", x1);
printf("x2 = %g\n", x2);
}
}
system("PAUSE");
return 0;
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus