Multiple choice question.

This is a discussion on Multiple choice question. within the C Programming forums, part of the General Programming Boards category; Dear Friends, I want to know witch one of the following choice is correct answer for the following sample code. ...

  1. #1
    Registered User ungalnanban's Avatar
    Join Date
    Feb 2010
    Location
    Chenai
    Posts
    12

    Thumbs up Multiple choice question.

    Dear Friends, I want to know witch one of the following choice is correct answer for the following sample code.

    Sample Code

    Code:
                    int sum_matrix (int m [][][], int 12, int y, int z){
                    int sum = 0;
                    int i, j, k;
                    for (k = 0; k <z; k++)
                    for (j = 0; j <y; j++)
                    for (i = 0; i <x; i++)
                    sum += m[k][j][i];
    
                    return sum;
                    }
    Question Which one of the following accurately describes the error in
    the function sum_matrix(), defined above?

    Choice 1 (_)
    The manner in which m is accessed by its indices does not parallel the
    loop structure and may not produce the desired sum.
    Choice 2 (_)
    The matrix m has more dimensions than Standard C requires compliant
    compilers to support.
    Choice 3 (_)
    The compiler lacks sufficient information to generate pointer
    arithmetic code for m.
    Choice 4 (_)
    C does not support multidimensional arrays; it only supports arrays of
    arrays.
    Choice 5 (_)
    Assuming that x, y, and z represent the bounds of the array, an

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
     int sum_matrix (int m [][][], int 12, int y, int z){
                    int sum = 0;
                    int i, j, k;
                    for (k = 0; k <z; k++)
                    for (j = 0; j <y; j++)
                    for (i = 0; i <x; i++)
                    sum += m[k][j][i];
    
                    return sum;
                    }
    Choice 6 - None of the above.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,590
    Try compiling it, and figure out the answer from the error message you get.

    It is one of the answers listed.
    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. Returning multiple values from function??
    By AJOHNZ in forum C++ Programming
    Replies: 3
    Last Post: 08-18-2009, 03:42 AM
  2. Replies: 16
    Last Post: 06-08-2009, 03:03 PM
  3. Menu Help
    By CJ7Mudrover in forum C Programming
    Replies: 7
    Last Post: 03-09-2004, 08:59 AM
  4. Multiple Choice!!!
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 09-08-2002, 02:30 PM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM

Tags for this Thread


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