Multiplication Table A multiplication table shown below is a

Multiplication Table A multiplication table (shown below) is a tool commonly used by children in elementary school to help them learn to multiply numbers. The top row consists of integers from 0 to 12, increasing from left to right, while the leftmost column consists of integers from 0 to 12 increasing from top to bottom (the top-left corner contains an \"X\" to denote the multiplication operation). Every other element in the multiplication table is the product of the number at the very top of its column and the number at the very left of its row. Write a MATLAB script to create an array that contains the multiplication table as shown below-but instead of an \"X\" in the top-left corner, put a zero (0) in the (1, 1) element of your array.

Solution

% maximum number to use in multiplication table
N = 12;

% print description to command window
fprintf(\'Multiplication Table\ \')

% The outer loop cycles through the rows.
% The inner loop cycles along the columns of each row
% Because each loop executes N times, the total number of number printed
% will be N^2
for i=1:N
    for j=1:N
       fprintf(\'%3i \',i*j) % prints a number without starting a new line
    end
    fprintf(\'\ \')             % prints a carriage return to start a new line
end

 Multiplication Table A multiplication table (shown below) is a tool commonly used by children in elementary school to help them learn to multiply numbers. The

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site