MATLAB: How to print out a product of 2 requested numbers

functionsprint function

I need to write a function that requests the user to input 2 numbers one by one and then prints them and their prodct according to:
(I'm using the example numbers it gives me)
>> print_product Give me a number: 4 Give me another number: 7 The product of 4 and 7 is 28.
function [] = print_product ()
clc
x = input('Give me a number: ', 's');
y = input('Give me another number: ', 's');
z = x*y;
fprintf ('The product of x and y is z ')

Best Answer

function print_product()
x = str2double(input('Give me a number: ', 's'));
y = str2double(input('Give me another number: ', 's'));
z = x*y
fprintf('The product of %d and %d is %d',x,y,z)
end