Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6109471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:24:31+00:00 2026-05-23T14:24:31+00:00

I want to change rows into column and column into rows of that 2-D

  • 0

I want to change rows into column and column into rows of that 2-D array

I want a program which takes input and gives output as below.

Input:   1    2    3                       
         4    5    6

Output:  1    4
         2    5
         3    6

Input:   1    2    3
         4    5    6
         7    8    9

Output:  1    4    7
         2    5    8
         3    6    9

I did a sample which in hardcoded array as below

int main()
{
    int i,j;
    int grades[2][3] = { {55, 60, 65},
                                           {85, 90, 95} 
                                        };
    for( j = 0; j < 3; j++)
    {       
      for( i = 0; i < 2;i++)
      {
         printf("%d\t",grades[i][j]);
      }
      printf("\n");
    }

    return 0;
}

Its long time since i programmed in C , is there anyway we can make things dynamic or better way of doing the same. Right now its hardcoded.

I remember we have to use malloc or so , is that right.

psuedo code is also fine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:24:31+00:00Added an answer on May 23, 2026 at 2:24 pm
    void main()
    
    {
    
       clrscr();
    
       int in[10][10];
       int out[10][10];
    
       int row,column,i,j;
       printf("enter row");
       scanf("%d",&row);
       printf("Enter column");
       scanf("%d",&column);
       //storing values in matrix
       for(i=1;i<=row;i++)
       {
          for(j=1;j<=column;j++)
          {
            printf("Enter (%d,%d)th value",i,j);
            scanf("%d",&in[i-1][j-1]);
          }
       }
       //show stored values
       printf("\ninput is\n\n");
       for(i=0;i<row;i++)
       {
          for(j=0;j<column;j++)
          {
            printf("%d\t",in[i][j]);
          }
          printf("\n");
       }
       //show transposed value. it is also stored in out matrix
       printf("\nOutput is\n\n");
       for(i=0;i<column;i++)
       {
          for(j=0;j<row;j++)
          {
            printf("%d\t",in[j][i]);
            out[i][j]=in[j][i];
          }
          printf("\n");
       }
    
       getch();
    
    }
    

    //////////////////////////////////////

    input matrix is stored in in[][] matrix and output matrix stored in out[][] matrix.
    this program will work for any matrix with row and column below 10 if we increase the matrix variable value ,it will work for larger matrix also .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get relevant rows into datatable, i want only rows that have
I want to change the Color of Rows. Like, Change the color of of
I want to perform action on change in count of rows of an HTML
I have an internal table itab which has some rows that one component of
I have a quadratic matrix(two-dimensional dynamic array of pointers) and need to change rows/columns
I have a function that I have implemented as a VBA module which takes
Please guide me as how to sort an array with taking into consideration that
I am trying to take a stored procedure that copies parent/child/grandchild rows into the
I have a GridView with a button which sets all rows into edit mode
I have a program that I use to enter values into a database using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.