Untitled
unknown
plain_text
5 years ago
991 B
15
Indexable
#include <stdio.h>
#include <stdlib.h>
void printMatrix(int *matrix, int row, int column);
int main(void)
{
int stu_id = 70357003;
int r, c;
printf("Enter the size of row for a matrix: ");
scanf("%d", &r);
printf("Enter the size of column for a matrix: ");
scanf("%d", &c);
int mat[r][c];
for(int i = 0; i < r; i++){
for(int j = 0; j < c; j++){
printf("Enter value for Matrix[%d][%d]: ", i+1, j+1);
scanf("%d", &mat[r][c]);
}
}
printMatrix(mat, r, c);
printf("\n\nStudent ID: %d\n\n", stu_id);
return 0;
}
void printMatrix(int *matrix, int row, int column){
printf("Matrix in 2D format:\n");
int count = 0;
for(int i = 0; i < row; i++){
for(int j = 0; j < column; j++){
printf("%d ", *(matrix + count));
if(j == column - 1){
printf("\n");
}
count++;
}
}
}Editor is loading...