Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

modify the program so that the user is asked to type in the value of the base, if an invalid base number is entered the

modify the program so that the user is asked to type in the value of the base, if an invalid base number is entered the program will ask again until a correct value is entered.

#include

int main(void)

{

void scalarmultiply (int nrows, int ncols, int matrix[nrows][ncols], int scalar);

void displaymatrix (int nrows, int ncols, int matrix[nrows][ncols]);

int samplematrix[3][5] =

{

{7, 16, 55, 13, 12},

{12, 10, 52, 0, 7},

{-1, 1, 2, 4, 9}

};

printf("original matrix: ");

displaymatrix (3, 5, samplematrix);

scalarmultiply (3, 5, samplematrix, 2);

printf(" Multiplied by 2: ");

displaymatrix(3,5, samplematrix);

scalarmultiply (3,5, samplematrix, -1);

printf (" then multiplied by -1: ");

displaymatrix(3,5,samplematrix);

return 0;

}

void scalarmultiply (int nrows, int ncols, int matrix[nrows][ncols], int scalar)

{

int row, column;

for (row = 0; row < nrows; ++row)

for(column = 0; column < ncols; ++column)

matrix[row][column] *= scalar;

}

void displaymatrix ( int nrows, int ncols, int matrix[nrows][ncols])

{

int row, column;

for( row = 0; row < nrows; ++row)

{

for( column = 0; column < ncols; ++column)

printf("%5i", matrix[row][column]);

printf(" ");

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions