0
I’m doing an activity and she says:
(function - matrix and vector) Design a program that reads a 4x4 matrix and creates a 4-element vector consisting of the elements of a matrix line chosen by the user my problem is that I don’t know how to make it print exactly the line chosen by the user.
My show just turned out to be this
#include <stdio.h>
int main() {
 
float matriz[4][4];
int d;
/* Entrada de dados na matriz */
printf(" Informe o valor de cada elemento -----\n");
for(int i=0; i<2; i++){
 for(int j=0; j<2; j++)
 {
 printf(" \n matA(%d,%d) = ", i+1,j+1);
 scanf("%f", &matriz[i][j]);
 }
}
// escolha da linha
printf("escolha a linha desejada:");
scanf("%d",&d);
/* Escrita da matriz - saída formatada */
printf(" \n A matriz informada eh = \n");
for(int i=0; i<2; i++)
{
 printf(" \n ");
 for(int j=0; j<2; j++)
 printf(" %4.1f ", matriz[i][j]);
}
}
						
Have you considered not using a loop for the line (iindex
i) and instead informd?for(int j=0; j<2; j++) printf(" %4.1f ", matriz[d][j]);– anonimo