Write a program that creates a two dimension matrix of size N x N (N is larger than 4). Through a menu, the user can choose to perform the following operation to the matrix.

1 - Rotate the matrix around the diagonal (function name rotateDiagonal)

Example for 3 x 3 matrix :

1 2 3 - 1 4 7
4 5 6 - 2 5 8
7 8 9 - 3 6 9

2 - Rotate the matrix around the middle row (function name rotateRow)

1 2 3 - 7 8 9
4 5 6 - 4 5 6
7 8 9 - 1 2 3

3 - Rotate the matrix around the middle column (function name rotateColumn)

1 2 3 - 3 2 1
4 5 6 - 6 5 4
7 8 9 - 9 8 7

4 - Set the upper triangle to zero (function name setUpperZero)


1 2 3 - 1 0 0
4 5 6 - 4 5 0
7 8 9 - 7 8 9

Write your program such that the user enters the values of the matrix, and each operation of the above is performed by a function as indicated above. Use the (switch) structure to call the functions.

The user menu can be as follows

1 - Enter Matrix Values
2 - Rotate around Diagonal
3 - Rotate around the middle row
4 - Rotate around the middle column
5- Set the upper triangle to zero

Enter your option ?


we cant seem to start with this program..
we seek help from C language experts in sorting out this problem and has the know-how knowledge to get us onto the right track..
please do help us..

Recommended Answers

All 5 Replies

Member Avatar for iamthwee

> please do help us.
Help yourself by creating at least a skeleton program. Draw a flow chart on paper to get you started and use google for help...

pls try to come down with ur programming for the of the beginners.

your going to use 2 dimensional arrays

Don't expect someone here to give you the immediate answer
try coding your work and we'll help you if you have any problems

Setting the upper right triαng£e to 0 :

// a[ ][ ] is the 2-D matrix..

for( i=0 ; i < n ; i++ )
for( j=0 ; j < n ; j++ )
{
if( j > i )
a[ i ][ j ]=0;
}

Eg :
1 0 0 0
5 6 0 0
9 0 4 0
8 9 6 1

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.