Thread: 2 dimensional array!!!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    7

    2 dimensional array!!!

    As of now my program as the user input an expression like *2x and then the program outputs it as

    *
    2
    x

    I am wanting to display zeros next to the elements, 2 columns of zeros so the output will be

    * 0 0
    2 0 0
    x 0 0

    This is my code
    Code:
    int main()
    {
    
    string s;
    cout << "Input the prefix expression.\n" ;
    cin >> s;
    cout << "The expression tree is:\n" ;
    
    int row = s.length();
    int col = 2;
    int array[row][col];
    int i, j, c;
    
    for (j = 0; j < row; j++)
    for (c = 0; c < col; c++)
    for (i = 0; i < s.length(); i++)
    {
    cout << s[i] << array[row][col] << endl ;
    }
    it outputs

    *2293584
    22293584
    x2293584
    *2293584
    22293584
    x2293584
    *2293584
    22293584
    x2293584
    *2293584
    22293584
    x2293584

    Edit/Delete Message
    Last edited by whitey300; 10-21-2009 at 03:06 PM. Reason: email

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  2. two dimensional array
    By leisiminger in forum C Programming
    Replies: 12
    Last Post: 03-09-2008, 11:53 PM
  3. Type and nontype parameters w/overloading
    By Mr_LJ in forum C++ Programming
    Replies: 3
    Last Post: 01-02-2004, 01:01 AM
  4. Replies: 5
    Last Post: 11-20-2001, 12:48 PM