I need help, I could not do this question. Write a program in C which asks the u
ID: 3593601 • Letter: I
Question
I need help, I could not do this question.
Write a program in C which asks the user for a 2x5 integer matrix, and an integer multiplier. Your program must send these two variables to a function named expand) and this function must display your matrix, scaled by your imultiplier. Sample Run Enter your matrix: 9 201468537 Enter multiplier: 3 Result: 99 9 2 2 2 0 0 01 1 1 4 4 4 99 9 2 2 2 0 0011 1 4 4 4 99 9 2 2 2 0 0011 1 4 4 4 6 6 6 8 8 8 5 5 5 3 3 3 7 7 7 6 6 6 8 8 8 5 5 5 3 3 3 7 7 7 6 6 6 8 8 8 5 5 5 3 3 3 7 7 7Explanation / Answer
# include <stdio.h>
int expand(mat[][], multiplier);
int main(){
int i, j, k, row, col ;
int mat[row][col];
int multiplier;
printf("Enter the 2X5 matrix:");
for(i=0;i<row;i++){
for(j=0;j<col;j++){
scanf("%d",&mat[i][j]);
}printf(" ");
}
printf("Enter the multiplier:");
scanf("%d",&multiplier);
for(i=0; i<row; i++){
for(j=0; j< col; j++){
printf("%d ",mat[i][j]);
}
printf(" ");
}
}
int expand(mat[][],multiplier){
int tot,Total;
tot = (row*col*multiplier*multiplier);
int newMatrix[tot];
Total = 0;
for(i=0; i<row; i++){
for(j=0; j< col; j++){
for(k=0; k<(multiplier*multiplier);k++){
newMatrix[Total] = mat[i][j];
Total = Total + 1;
}
}
}
for(i=0;i<multiplier;i++){
for(int l=0;l<Total/2;l=l+multiplier*multiplier){
for(k = 0 ; k < multiplier ; k++){
printf("%d ",newMatrix[k+l]);
}
}printf(" ");
}
for(i=0;i<multiplier;i++){
for(int l=(Total/2)+1;l<Total;l=l+multiplier*multiplier){
for(k = 0 ; k < multiplier ; k++){
printf("%d ",newMatrix[k+l]);
}
}printf(" ");
}
}