-
having trouble help
trying to do crammers rule what im doing wrong
int number
int a;
int b;
int c;
int d;
int e;
int f;//values of intergers
double x1 ;//value of x
double z ;// value of x1/x2
double y1 ;//value of y
cout << "Please enter integers values for a " << endl;
cin >> number;
cout << "Please enter integers values for b " << endl;
cin >> number;
cout << "Please enter integers values for c " << endl;
cin >> number;
cout << "Please enter integers values for d " << endl;
cin >> number;
cout << "Please enter integers values for e " << endl;
cin >> number;
cout << "Please enter integers values for f " << endl;
cin >> number;
x1 =e*c-f*b ;
z=a*e-b*d ;
y1=a*f-d*c;
cout << "x = " << z/x1 << endl;
cout << "y = " << z/ y1 << endl;
im trying to put this equations
x = (c e - f b) / D and y = (a f - d c) / D
and x = a e - b d.
its the crammer rule but i cannot figure out how to put it on a c++ program any help is not coming up right this is what i got
x1 =e*c-f*b ;
z=a*e-b*d ;
y1=a*f-d*c;
-
Firstly, read this. It gives advice on asking questions in a way that is more likely to elicit a response.
Computers are ignorant machines. C++ compilers are ignorant programs that run on ignorant machines. Your source code is therefore a series of instructions that will be interpreted literally by an ignoramus. If you write the code imprecisely, that ignoramus will give you the wrong results, over and over .....
Given the code;
Code:
cout << "Please enter integers values for a " << endl;
cin >> number;
cout << "Please enter integers values for b " << endl;
cin >> number;
our ignoramus practices no magic. It stores both values input by the user into variable "number". The first value is not magically copied to the variable a and the second value input is not copied magically into the variable b. In the code, I've quoted the first instance of "cin >> number;" needs to be replaced with "cin >> a;" and the second by "cin >> b;".
Incidentally, the rule you're trying to code up is "Cramer's". There is only one 'm'. People can cope with imprecision only so far.
-