CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2013
    Posts
    1

    Help: 2-dimensional array

    1. Create one 2-dimensional array. The array will consist of numbers from 1 to 10. And will also contain the number in words. Display the values of the 2-dimensional array.
    Sample output:
    1 – One
    2 – Two
    3 – Three
    Paste the program code here:


    2. Create a program that will accept two integer numbers. These integer numbers will be the limit of the multiplication table. Store the values in a two dimensional array.
    Sample output:
    Enter x: 3
    Enter y: 2
    1 2 3
    2 4 6
    Paste the program code here:


    3. Determine the output produced by the following program segment.
    int ROWS = 3;
    int COLS = 4;
    int [ ] [ ] val = {{8,16,9, 52},{3,15,27,6},{14,25,2,10}};
    for (int i=0; i < ROWS; i++)
    {
    for (int j= 0; j<COLS; j++)
    System.out.print (val [i][j] + “ ” );
    System.out.println ();
    }

    Write the Output:

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Help: 2-dimensional array

    Please read this

    http://forums.codeguru.com/showthrea...ork-assignment

    and then post your specific programming question.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #3
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Help: 2-dimensional array

    Not even a please. Nice.

  4. #4
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Help: 2-dimensional array

    Code:
    int ROWS = 3;
    int COLS = 4;
    int [ ] [ ] val = {{8,16,9, 52},{3,15,27,6},{14,25,2,10}};
    for (int i=0; i < ROWS; i++)
    {
    for (int j= 0; j<COLS; j++)
    System.out.print (val [i][j] + “ ” );
    System.out.println ();
    }
    This is NOT c++ code. This looks like c# code. This is a c++ forum!

    Moderator - please would you move this thread to the correct forum.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  5. #5
    Join Date
    Jan 2009
    Posts
    596

    Re: Help: 2-dimensional array

    Quote Originally Posted by imbapaps View Post
    3. Determine the output produced by the following program segment.
    int ROWS = 3;
    int COLS = 4;
    int [ ] [ ] val = {{8,16,9, 52},{3,15,27,6},{14,25,2,10}};
    for (int i=0; i < ROWS; i++)
    {
    for (int j= 0; j<COLS; j++)
    System.out.print (val [i][j] + “ ” );
    System.out.println ();
    }

    Write the Output:
    You can't even be bothered to wrap this up into a complete program and run it to get the answer, yet you expect us to write two programs for you?

  6. #6
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Help: 2-dimensional array

    Quote Originally Posted by 2kaud View Post
    Code:
    int ROWS = 3;
    int COLS = 4;
    int [ ] [ ] val = {{8,16,9, 52},{3,15,27,6},{14,25,2,10}};
    for (int i=0; i < ROWS; i++)
    {
    for (int j= 0; j<COLS; j++)
    System.out.print (val [i][j] + “ ” );
    System.out.println ();
    }
    This is NOT c++ code. This looks like c# code. This is a c++ forum!

    Moderator - please would you move this thread to the correct forum.
    I'd rather say it's Java.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  7. #7
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Help: 2-dimensional array

    I'd rather say it's Java.
    Java? Java???? Oh yes, that which our security auditors keep telling us to disable. I never touch it!
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured