Question: Times table A time table gives the product between two integers. Ex: 5 times 5 is 25, 5 times 6 is 30, 12 times 12,
Times table
A time table gives the product between two integers. Ex: 5 times 5 is 25, 5 times 6 is 30, 12 times 12, etc. Write a function called timesTable that outputs a times tables up to the size requested, given by a positive integer sizeOfTable. The top row and left column have integers from 1 to the desired size. If sizeOfTable is:
negative, then the absolute value of sizeOfTable should be used to calculate the table.
is not an integer, the table should be calculated to the nearest integer greater than or equal to sizeOfTable.
Restrictions: The timesTable function should only use while loops.
What I Have below may be wrong...
function outputMatrix = timesTable( sizeOfTable)
% Insert code to determine the size of the times table size=round(abs(sizeOfTable)); % Insert code to initialize the table by filling all entries with zeros outputMatrix=zeros(size); % Insert code to fill the first column and first row with consecutive integers % starting with 1 outputMatrix(1,:)=[1:size]; outputMatrix(:,1)=[1:size]; % Use a loop structure to fill the remaining entries in the times table end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
