add element of matrix-Urgent

This is a discussion on add element of matrix-Urgent within the C Programming forums, part of the General Programming Boards category; Please , I need some help to add the elements of a matrix. my program must read several matrices from ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    39

    add element of matrix-Urgent

    Please , I need some help to add the elements of a matrix.

    my program must read several matrices from a file and add all element for each matrix.

    This is how I did it

    Code:
    for(i=0;i<size;i++)
    {
    for(j=0;j<size;j++)
    sum=sum+A[i][j];
    }
    I initialized sum BEFORE the while loop (which is set to read all matricces unitil the end of file).
    size is the size of the matrix.

    I get wrong results.
    can someone tell me what I am doing wrong?

    thank you
    B

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,540
    After you've read the matrices in, print them out to make sure they look good.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. *operator overloading: scalar matrix multiplication
    By gemini_shooter in forum C++ Programming
    Replies: 4
    Last Post: 06-08-2009, 01:14 PM
  2. Simple operator overloading issue
    By Desolation in forum C++ Programming
    Replies: 1
    Last Post: 05-09-2007, 08:56 PM
  3. Weird errors.
    By Desolation in forum C++ Programming
    Replies: 20
    Last Post: 05-09-2007, 01:10 PM
  4. Replies: 1
    Last Post: 03-06-2006, 06:57 PM
  5. How to add element to the end of a linked list?
    By Yin in forum C++ Programming
    Replies: 3
    Last Post: 04-22-2002, 03:04 PM

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