this is my 1st attempt with pointers and I can't get this program to tell if there not real or to produce roots. Any help would be great... cuz I know its not 0.000 0.000 thanks
Code:
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <cmath>
using namespace std;
void readabc(double *a, double *b, double *c, char *real);
void quadroots(double *a,double *b,double *c,double *root1,double *root2, char *real);
int main()
{
double a, b, c, root1, root2;
char real;
readabc( &a, &b, &c, &real);
quadroots(&a, &b, &c, &root1, &root2, &real);
real = b*b-4*a*c<0;
real==1;
root1=(-b+sqrt(b*b-4*a*c)/(2*a));
root2=(-b-sqrt(b*b-4*a*c)/(2*a));
return 0;
}
void readabc(double *a, double *b, double *c,char *real)
{
cout << "Enter a,b,c for a quad: " << endl;
cin >> *a >> *b >> *c;
return;
}
void quadroots(double *a,double *b,double *c,double *root1,double *root2, char *real)
{
if (!*real)
{
printf("roots are not real\n");
}
else
{
printf ("roots are %lf %lf\n", *root1, *root2);
}//check for real roots and calculate root1 and root2
}