c++ help needed

Discussion in 'The Lounge' started by hamid.mehmood, Jan 7, 2010.

  1. hamid.mehmood

    hamid.mehmood

    Joined:
    Jan 7, 2010
    Messages:
    1
    Likes Received:
    0
    I am new at C++ and really don't know how to print two, two dimensional arrays side by side. Can someone help me out in this.
     
    hamid.mehmood, Jan 7, 2010
    #1
    1. Advertisements

  2. hamid.mehmood

    alphah

    Joined:
    Jun 14, 2010
    Messages:
    37
    Likes Received:
    0
    you need a for-loop like this

    for (int i = 1; i <10; ++i) {
    for (int j = 1; j < 10++j) {
    print(A[j];
    }
    }
     
    alphah, Jun 18, 2010
    #2
    1. Advertisements

  3. hamid.mehmood

    alphah

    Joined:
    Jun 14, 2010
    Messages:
    37
    Likes Received:
    0
    sorry a typo
    in c++ array counts from 0
    so you would do

    int i = 0; ...
    int j = 0...
     
    alphah, Jun 18, 2010
    #3
  4. hamid.mehmood

    alphah

    Joined:
    Jun 14, 2010
    Messages:
    37
    Likes Received:
    0
    and to do the print, you will do

    cout

    you need to include #include<iostream>
     
    alphah, Jun 18, 2010
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.