CPP Assignment 2
CPP Assignment 2
void arrayFunc(int num[],int size , int sum) To find all pairs of elements in an
Sample
Output :
Example:
Input :
int[] A = { 1, 5, 6, 7, 8, 10 }
int[] B = { 2, 4, 9 }
Output:
Sorted Arrays:
A: [1, 2, 4, 5, 6, 7]
B: [8, 9, 10]
Q3.Write a program to declare a square matrix A[ ][ ] of order MxM where ‘M’ is the number of
rows and the number of columns, such that M must be greater than 2 and less than 10. Accept the
value of M as user input. Display an appropriate message for an invalid input. Allow the user to
input integers into this matrix. Perform the following tasks:
(a) Display the original matrix.
(b) Rotate the matrix 90° clockwise as shown below:
(c) Find the sum of the elements of the four corners of the matrix.
Test your program for the following data and some random data:
Example 1
INPUT :
M = 3
OUTPUT :
ORIGINAL MATRIX