having trouble help

This is a discussion on having trouble help within the C++ Programming forums, part of the General Programming Boards category; trying to do crammers rule what im doing wrong int number int a; int b; int c; int d; int ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    3

    Unhappy 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;

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,261
    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.
    Last edited by grumpy; 02-05-2011 at 02:29 PM.
    Right 98% of the time, and don't care about the other 3%.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New to C trouble with strtok and storing the values
    By robin2aj in forum C Programming
    Replies: 5
    Last Post: 03-18-2010, 06:52 AM
  2. Replies: 6
    Last Post: 01-03-2007, 02:02 PM
  3. Is it so trouble?
    By Yumin in forum Tech Board
    Replies: 4
    Last Post: 01-30-2006, 03:10 PM
  4. trouble scanning in... and link listing
    By panfilero in forum C Programming
    Replies: 14
    Last Post: 11-21-2005, 11:58 AM
  5. C++ program trouble
    By senrab in forum C++ Programming
    Replies: 7
    Last Post: 04-29-2003, 11:55 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21