Below is my source code, it won't compile and says that there is a Microsoft Run-Time error (1.#IND), can anyone help me out? Thanks!

``````/*Program: hwassign3.cpp
Author: Melissa Hubbard
Date: January, 31, 2005
Purpose: This program was designed to take information from a user and
the equation.
*/
#include "stdafx.h"
#include <cmath>
#include<iostream>
using namespace std;

int main (){

double A,B,C; /*variables to get from user*/
double xpos; /*used to get positive answer*/
double xneg; /*used to get negative answer*/

cout<<"Please enter the number that represent A: ";
cin>>A;
cout<<"Please enter the number that represent B: ";
cin>>B;
cout<<"Please enter the number that represent C: ";
cin>>C;

if ((A=0)||(((B*B-4*A*C))<=0));

else
{
xpos=((-B+sqrt((B*B)-4*A*C))/(2*A));
cout<<"The positive answer is: " <<xpos;
xneg=((-B-sqrt((B*B)-4*A*C))/(2*A));
cout<<"The negative answer is: " <<xneg;
}
system("PAUSE");
return 0;
}
``````

Edited by pyTony: fixed formating

2
Contributors
3
Replies
4
Views
13 Years
Discussion Span
Last Post by Dave Sinkula

Dividing by zero?

``if ( (A=0)||(((B*B-4*A*C))<=0) );``

This assigns 0 to A. Doesn't your compiler give you a warning?

I don't get a warning, but this is what I am trying to do-->verify that A (not equal) to 0, B*B-4AC>=0...can you help me in forming this parameter?

Dividing by zero?

``if ( (A=0)||(((B*B-4*A*C))<=0) );``

This assigns 0 to A. Doesn't your compiler give you a warning?

Comparison:

``A == 0``

Assignment:

``A = 0``
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.