0% found this document useful (0 votes)
3 views3 pages

Matrix

The document outlines a series of C programming tasks involving matrix manipulations. Each task requires reading a matrix, performing specific operations such as transposing, replacing non-prime numbers, calculating sums of diagonals, and modifying elements based on certain conditions. The tasks also include functions for finding nearest odd numbers and multiples of 5, along with displaying the final results for each operation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Matrix

The document outlines a series of C programming tasks involving matrix manipulations. Each task requires reading a matrix, performing specific operations such as transposing, replacing non-prime numbers, calculating sums of diagonals, and modifying elements based on certain conditions. The tasks also include functions for finding nearest odd numbers and multiples of 5, along with displaying the final results for each operation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Solve the questions using functions:

1. **Transpose and Replace Non-Primes**

Write a C program to:

- Read a matrix of order (mxn)

- Calculate the transpose of the matrix.

- Replace all non-prime numbers in the transposed matrix with -1.

- Display the final matrix.

2. **Sum of Diagonal Primes**

Write a C program to:

- Read a square matrix of order ( m x n ).

- Find and display the sum of all prime numbers present in the diagonals of the matrix.

3. **Matrix Prime Count and Replacement**

Write a C program to:

- Read a matrix of order \( M \times N \).

- Count the total number of prime numbers in the matrix.

- Replace each prime number with its square in the matrix.

- Display the matrix along with the count of prime numbers.

4. **Nearest Odd Number Replacement**

Write a C program to:

- Read a matrix of order \( M \times N \).

- Write a function `NearestOdd()` that takes a number and returns the nearest odd number (if
even, reduce by 1, if odd, return itself).

- Replace all even numbers in the matrix with the nearest odd number using the
`NearestOdd()` function.

- Display the final matrix.

---

5. **Sum of Diagonal Elements**

Write a C program to:


- Read a square matrix of order ( m x n).

- Find and display the sum of all elements present in both the main and secondary diagonals
of the matrix.

6. **Row-wise Average Replacement**

Write a C program to:

- Read a matrix of order ( M x N ).

- Calculate the average of each row.

- Replace each element in a row with the average of that row.

- Display the final matrix.

7. **Nearest Multiple of 5 Replacement**

Write a C program to:

- Read a matrix of order ( M x N ).

- Write a function `NearestMultipleOf5()` that takes a number and returns the nearest
multiple of 5 (rounding up if equally close to two multiples).

- Replace each element in the matrix with its nearest multiple of 5 using the
`NearestMultipleOf5()` function.

- Display the final matrix.

8. **Column-wise Maximum Replacement**

Write a C program to:

- Read a matrix of order ( M x N ).

- Find the maximum element in each column and replace all elements in that column with the
maximum value.

- Display the final matrix.

9. **Reverse Each Row**

Write a C program to:

- Read a matrix of order \( M \times N \).

- Reverse the elements of each row.

- Display the matrix with each row reversed.

You might also like