Wednesday 23 January 2013

Returning values from fuction and also passing value to the function in matlab



%--------------Returning values from fuction and also passing value to the functions-------%

a=input('Enter 1st num\n');
b=input('Enter 2nd num\n');
c=input('Enter 3rd num\n');
p=ret(a,b,c);
fprintf('the product of your 3 number is=%d\n',p);
%--------------===============================--------------------------------------------%


  function[z]=ret(a,b,c);
z=a*b*c;

basically in c,c++ we use this syntax as
z=a*b*c;
return z;
but here we return z as
function[z]=ret(a,b,c);
which mean that we return the value of z after calculation to the function ret(a,b,c)which
also contain 3 parameter variable%--------------------------------
 

0 comments:

Post a Comment