Swapping Rows and Columns in a 2D array

This is a discussion on Swapping Rows and Columns in a 2D array within the C Programming forums, part of the General Programming Boards category; I need help with this problem Write a program with a function called ManipulateArray. This function should accept a 2 ...

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

    Post Swapping Rows and Columns in a 2D array

    I need help with this problem

    Write a program with a function called ManipulateArray. This function should accept a 2 dimensional array of size 5 by 5 and perform the following

    Initialize this array with values upon declaration
    Reverse the first column
    print the array on the screen
    Swap the contents of column 3 and column 4
    print the array on the screen
    Sort row 5 in descending order
    Sum the contents of the entire array
    Your program should define a function call print, to print the array each time it is required.

    this is what I have :

    Code:
    #include <stdio.h>
    #include <conio.h>
    #include <iostream>
    #include <ctype.h>
    
    #define ROW 5
    #define COL 5
    
    
    void ManipulateArray (int[][]);
    
    
    int main()
    {
      int array [ROW][COL]={ {2,4,6,8,10},{12,14,16,18,20},{22,24,26,28,30},{32,34,36,38,40},{42,44,46,48,50}};
    
        int i,j,sum=0;
    
    //Reverse the first column 
    //Print the array on the screen
    
    
    //Swap the contents of column 3 and column 4
    //Print the array on the screen
    
    //Sort row 5 in descending order
    
    //Sum the contents of the entire array
    
        return 0;
    }

  2. #2
    Registered User
    Join Date
    May 2009
    Location
    Look in your attic, I am there...
    Posts
    92
    It appears this is an exercise in using for loops and indexing, I would like to help you but you didn't post any attempted code. If you show me you have tried the problem -- beside just creating the variables -- I would be glad you help you and correct your code (I could post a tutorial about how to use for loops or arrays but I am sure a quick google search could illustrate it way better than anything I could make).
    Last edited by 127.0.0.1; 03-11-2010 at 12:03 PM. Reason: Spelling :/

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Other than posting your homework, what have you actually done on your own to solve any of these problems? Because in your hurry to do your own work, you seem to have left out your own work.


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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Swapping rows in a 2D array
    By bassist11 in forum C Programming
    Replies: 5
    Last Post: 03-11-2010, 11:04 AM
  2. For loop through a 2D array - just for select rows
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 04-17-2009, 08:34 AM
  3. matrix class
    By shuo in forum C++ Programming
    Replies: 2
    Last Post: 07-13-2007, 01:03 AM
  4. Addition of the rows and columns in an array.
    By Turtal in forum C Programming
    Replies: 4
    Last Post: 11-14-2006, 08:00 PM
  5. sum rows & columns in array
    By ronenk in forum C Programming
    Replies: 7
    Last Post: 06-20-2004, 04:16 AM

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