Thread: Just started c++ need help...(those who know basic matrices)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    3

    Just started c++ need help...(those who know basic matrices)

    Code:
    Hello all,
                Thank you all for taking some time to read and help. I have just started programming in c++. 
    I tried to make a program to solve two simulataneous eqns for eg ( 3x + y = 7, x - 2y =0... What is x and y?)
    I figured the only way to program this is to use the matrices method, which is finding the det and so on and so forth.
    
    Here is the source code ( x is the determinant) 
    
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        double a;
        double b;
        double c;
        double a1;
        double b1;
        double c1;
        double x = (1 / ((a * b1) - (b * a1)));
        
        cout<<"What is a? :";
        cin>> a;
        cout<<"What is b? :";
        cin>> b;
        cout<<"What is c? :";
        cin>> c;
        cout<<"What is a1? :";
        cin>> a1;
        cout<<"What is b1? :";
        cin>> b1;
        cout<<"What is c1 :";
        cin>> c1;
        cout<<"X = "<< (x * c * b1) + (x * c1 * -b);
        cin.ignore();
        cin.get();
        
        return 0;
    } 
    I tried it the forumula on paper and i can solve the problems fine but i cant seem to make it work.. 
    i get answers like = -1.#IF or something like dat .. I really dont know what im doing wrong. So please help me out here Thanks alot
    ps : this is supposed to find the value of X only(not the determinant)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~EDIT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    For those of you who do not understand how this is supposed to work... here is an example
    3x + y = 5
    x - 2y = -3
    therefore...
    a=3(coeff of x first line)
    b=1(coeff of y first line)
    c= 5
    a1=1(coeffe of x 2nd line)
    b1= -2(coeff of y 2nd line)
    c1 = -3
    Last edited by Bloodasp92; 12-04-2007 at 08:24 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Started using C++ Without Fear to learn--novice questions!
    By AvocadoRivalry in forum C++ Programming
    Replies: 6
    Last Post: 10-20-2008, 03:48 PM
  2. help me!!
    By lilmiss in forum C Programming
    Replies: 6
    Last Post: 09-23-2008, 04:51 PM
  3. Replies: 10
    Last Post: 11-23-2007, 12:13 AM
  4. Newbie needing help with basic code!
    By TeZ258 in forum C++ Programming
    Replies: 4
    Last Post: 11-03-2007, 08:35 PM
  5. Help with a Basic C Program!!
    By KIwi_Fella in forum C Programming
    Replies: 10
    Last Post: 11-01-2002, 10:04 AM