i am still confused here is my program so far do you see any changes?
#include <iostream>
#include <stdio.h>
#include "simpio.h"
#include "strlib.h"
#include "random.h"
#include "math.h"
using namespace std;
int main(double d, double, x, double, y)
{
int a, b, c, x, y, d;
printf("Enter A: ");
a = GetInteger();
printf("Enter B: ");
b = GetInteger();
printf("Enter C: ");
c = GetInteger();
d = (b*b-4*a*c)^(1/2);
x = ((-b - d)/(2.0*a));
y = ((-b + d)/(2.0*a));
if (x == y)
printf("There is one solution: %f\n", x);
else if (x != y)
printf("There are two solutions: %f and %f\n", x, y);
else if (d <= 0)
printf("There are no solutions.\n");
else
printf("There are no solutions.\n");
system("pause");
return 0;
}
First, make sure you are using a C compiler if this is a C program and make sure the extension at the end of the file is .c, not .cpp. If this is a C++ program, you're in the wrong forum. Assuming it is a C program and you are using a C compiler, this shouldn't compile due to these lines:
#include <iostream>
using namespace std;
You can't use those in C and your program doesn't need them anyway, so you can delete them. Also, you need to replace
with
I don't know what these files are, but I imagine GetInteger is in one of them.
#include "simpio.h"
#include "strlib.h"
#include "random.h"
Keep your main function as:
not
int main(double d, double, x, double, y)
Declare d, x, and y as doubles inside the program, where you are already declaring them as integers.
int a, b, c;
double x, y, d;
^ is not the exponential operator. Use pow or sqrt from math.h instead:
http://www.cplusplus.com/reference/c...cmath/pow.html
http://www.cplusplus.com/reference/c...math/sqrt.html
Keep in mind that 1 / 2 = 0 by integer division.
1.0 / 2.0 = 0.5, on the other hand, which is what you would want if you use the pow function.