changed ints to doubles [needs review]
This commit is contained in:
parent
818feb115d
commit
e4b2b15243
2 changed files with 6 additions and 6 deletions
4
main.c
4
main.c
|
@ -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);
|
||||||
|
|
||||||
|
|
|
@ -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");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue