changed ints to doubles [needs review]

This commit is contained in:
superdimensional 2021-04-27 03:18:35 -04:00
parent 818feb115d
commit e4b2b15243
2 changed files with 6 additions and 6 deletions

4
main.c
View file

@ -118,13 +118,13 @@ int main()
int numRows; int numRows;
int numColumns; int numColumns;
int scalar; double scalar;
printf("\nPlease enter the number of rows: "); printf("\nPlease enter the number of rows: ");
scanf("%d", &numRows); scanf("%d", &numRows);
printf("\nPlease enter the number of columns: "); printf("\nPlease enter the number of columns: ");
scanf("%d", &numColumns); scanf("%d", &numColumns);
printf("\nPlease enter the scalar multiplier: "); printf("\nPlease enter the scalar multiplier: ");
scanf("%d", &scalar); scanf("%lf", &scalar);
scalarMultiplication(numRows, numColumns, scalar); scalarMultiplication(numRows, numColumns, scalar);

View file

@ -57,9 +57,9 @@ int matrixAddition(int numRows, int numColumns)
return 0; return 0;
} }
int scalarMultiplication(int numRows, int numColumns, int scalar) int scalarMultiplication(int numRows, int numColumns, double scalar)
{ {
int matrix[numRows][numColumns]; double matrix[numRows][numColumns];
printf("\nEnter elements in matrix of size %d*%d! \n", numRows, numColumns); printf("\nEnter elements in matrix of size %d*%d! \n", numRows, numColumns);
@ -67,7 +67,7 @@ int scalarMultiplication(int numRows, int numColumns, int scalar)
{ {
for (int j = 0; j < numColumns; j++) for (int j = 0; j < numColumns; j++)
{ {
scanf("%d", &matrix[i][j]); scanf("%lf", &matrix[i][j]);
} }
} }
@ -76,7 +76,7 @@ int scalarMultiplication(int numRows, int numColumns, int scalar)
{ {
for (int j = 0; j < numColumns; j++) for (int j = 0; j < numColumns; j++)
{ {
printf(" %d ", matrix[i][j] * scalar); printf(" %lf ", matrix[i][j] * scalar);
} }
printf("\n"); printf("\n");
} }