try, for instance
#include <iostream>
using namespace std;
int main()
{
double a,b;
cout << "the equation is 'ax+b = 0'" << endl;
cout << "please enter the value of 'a'" << endl;
cin >> a;
cout << "now, please enter the value of 'b'" << endl;
cin >> b;
if ( a != 0.0)
cout << "the value of 'x' is " << (-b/a) << endl;
else
cout << "sorry, unable to find out the value of 'x'" << endl;
}
[update]
If you need to accept from the user a single string like, for instance
23.75 x + 10.18 = 0
The you have to build a (simple) parser in order to
- formally validate the equation
- extract the values
a = 23.75
, b = 10.18
.
Google is you friend[
^].
[/update]