24BCE513 Practical5
24BCE513 Practical5
Roll no:24BCE513
Course code:0CS501CC23
Practical 5:
Related to 1-D and 2-D array manipulations:
a) Write a program
- To read data from keyboard and store into 1-D array
- To read data from array and copy its square back to another array -
- To reverse all elements of original array
- To find out maximum element of an original array and print its location
b) Write a program to find transpose of a matrix and find whether it is symmetric or not.
a)
Code:
#include <stdio.h>
#define SIZE 5
scanf("%d", &arr[i]);
}
void squareArray(int arr[], int result[], int size) {
int temp;
temp = arr[i];
arr[size - i - 1] = temp;
max = arr[i];
index = i;
int main() {
readArray(arr, SIZE);
printf("\n");
reverseArray(arr, SIZE);
printf("\n");
findMax(arr, SIZE);
return 0;
Output:
b)
#include <stdio.h>
#define ROWS 3
#define COLS 3
printf("\n");
}
}
void transposeMatrix(int matrix[ROWS][COLS], int transpose[ROWS][COLS]) {
for (int i = 0; i < ROWS; i++) {
for (int j = 0; j < COLS; j++) {
transpose[j][i] = matrix[i][j];
}
}
}
}
return 1;
}
int main() {
int matrix[ROWS][COLS], transpose[ROWS][COLS];
readMatrix(matrix);
transposeMatrix(matrix, transpose);
printMatrix(transpose);
if (isSymmetric(matrix, transpose)) {
printf("The matrix is symmetric.\n");
} else {
return 0;
}
Output: