Thread: Assignment help

  1. #1
    Registered User
    Join Date
    Mar 2014
    Posts
    20

    Angry Assignment help

    3 - Matrix Print
    Write a void function called matrixPrint that has a single two-dimensional array parameter. The function should print the contents of its parameter. The size of its parameter should be specified with the defined constants ROW and COLUMN that represent the values 3 and 4 respectively. The function prototype is shown below.

    void matrixPrint(int m[ROW][COLUMN]);


    The output should be printed neatly in rows and columns, with a field width of 4.

    Code:
    If m1 is defined as: int m1[ROW][COLUMN] = { {1,2,3,4}, {2,3,4,5}, {3,4,5,6} };
    Then matrixPrint(m1);  should display the output shown below.
    1 2 3 4
    2 3 4 5
    3 4 5 6

    Code:
    #include "stdio.h"
    
    
    const int ROW = 3;
    const int COLUMN = 4;
    
    
    
    
    
    
    int main()
    {
        // Matrix Addition Test----------------------------
      int m1[ROW][COLUMN];
      int m2[ROW][COLUMN];
      int m3[ROW][COLUMN];
    return 0;
    }

  2. #2
    Registered User
    Join Date
    Mar 2014
    Posts
    20
    I have:

    Code:
    void matrixPrint(int m[ROW][COLUMN])
    {
    	int matrix[3][4] ={ {1,2,3,4}, {2,3,4,5}, {3,4,5,6} };
    
    
    	int row, column;
    
    
    	for(row = 0; row < 3; ++row){
    		for(column = 0; column < 5; ++column){
    			printf("%4d", matrix[row][column]);
    		}
    		printf("\n");
    	}
    }
    ************But is not right*************

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    I suggest writing a main to call the matrixPrint() function.
    I suggest compiling your code with warnings at a high level.

    I suggest posting the problem you are having instead of saying "But is not right".

    I suggest reading what you posted; because your code implies you never read it.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  4. #4
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    How many columns do you have?
    Code:
    column < 5
    Fact - Beethoven wrote his first symphony in C

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    I suggest reading the information on this link; then, re-reading the assignment.
    Functions in C - Cprogramming.com

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Assignment help
    By ADH94 in forum C Programming
    Replies: 33
    Last Post: 11-11-2012, 11:10 PM
  2. i seriously need help for my assignment :(
    By tianwu in forum C Programming
    Replies: 14
    Last Post: 11-26-2011, 01:34 PM
  3. Need help for my assignment .
    By kaizan777 in forum C Programming
    Replies: 2
    Last Post: 11-21-2011, 07:15 PM
  4. Need help with assignment
    By C_Davis in forum C Programming
    Replies: 4
    Last Post: 03-11-2010, 12:49 AM
  5. Replies: 3
    Last Post: 04-26-2009, 08:54 AM