Thread: 2 dimensional arrays

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    3

    2 dimensional arrays

    can someone please help with this

    i need to write a program that will create 2 matrices a[4][4] and b [4][4] each matrix should be filled with random integers from 0-10 using the rand function. then matrices a and b should be added and results put into matrix c. then it should calculate the determinants of a,b,and c and display then on the screen as well as the values of a, b and c. the program should use pointers only no indexes

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    What have you tried?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by naserian View Post
    i need to write a program that will create 2 matrices ... the program should use pointers only no indexes
    I can't wait to do this for you! I just love intentionally stupid program requirements!


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

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    The first step would be to try to solve the problem like any sane person would - using true 2D arrays.

    Then figure out how to obfuscate it with the "only pointers" bit.

    Does this mean that p[i] CANNOT be written as *(p+i) ?
    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.

  5. #5
    Registered User
    Join Date
    Mar 2010
    Posts
    3
    well my c is pretty bad. i can do part of it put with indexes and not with the rand function so that doesnt help me in anyway. i just really need the code

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    You get started, and people will help.

    You wait and keep asking for the codes, and you'll get nothing but unpleasant remarks.

    Your choice.

    Once you get started, using pointers instead of indexes, will be comfortable. I'm sure that's why you were given this assignment with these pointer requirements.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Three ONE dimensional arrays
    By victory1 in forum C Programming
    Replies: 5
    Last Post: 11-16-2009, 07:14 AM
  2. Pointers and multi dimensional arrays
    By andrea72 in forum C++ Programming
    Replies: 5
    Last Post: 01-23-2007, 04:49 PM
  3. Dynamic two dimensional arrays
    By ThWolf in forum C++ Programming
    Replies: 14
    Last Post: 08-30-2006, 02:28 PM
  4. two dimensional arrays
    By ssjnamek in forum C++ Programming
    Replies: 4
    Last Post: 05-01-2002, 08:12 PM
  5. Two dimensional arrays
    By Jax in forum C Programming
    Replies: 1
    Last Post: 11-07-2001, 12:53 PM