Can someone please explain it saying that
warning C4700: uninitialized local variable 'd' used?
Enhance the Quadratic program in the following manner. If the user enters a
valid set of coefficients (the else” case compute the value )of the discriminant d, defined as:
d = b^2 - 4ac
If the value of the discriminant is negative, inform the user that the roots are complex. If the
value is non-negative, inform the user the roots are not complex. Compile and run the program
multiple times. Verify the program acts as it should.
/////////////////////////////////////////////////////////////////////////////
//
// Name: Quadratic.cpp
// Author: Jeffrey A. Stone
// Course: CMPSC 101/121
// Purpose: Prompts the user for the three coefficients of a quadratic
// equation, and determines if the user has entered sufficient
// values to represent a quadratic equation.
//
/////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
/////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: main
// PARAMETERS: None
// RETURN TYPE: int
// PURPOSE: Entry point for the application.
//
/////////////////////////////////////////////////////////////////////////////
int main()
{
double a, b, c, d; // Initalizes and declares variables
std::cout << " Enter value of a: " <<endl; // Asks user for input of a....
cin >> a;
std::cout << " Enter value of b: " <<endl; // Ask user for input of b....
cin >> b;
std::cout << " Enter value of c: " <<endl; // Asks user for input of c....
cin >> c;
if ( a == 0 )
{
// not a quadratic equation, display an error message...
cout << "ERROR: the first coefficient must not be zero." << endl;
}
else
{
// a valid quadratic equation, display an error message...
cout << "The coefficients are valid." << endl;
}
if ( d < 1 )
{
d = ((pow (b,2)) - (4*a*c));
cout << "The determinant is: " << d << " and the roots are complex" << endl;
}
else
{
cout << "The determinant is: " << d << " and the roots are not complex" << endl;
}
// exit the program with success (0 == success)
return 0;
}