Filter löschen
Filter löschen

Help... what is my mistake and what should i do now?? please

2 Ansichten (letzte 30 Tage)
Abdur Rob
Abdur Rob am 25 Sep. 2020
Kommentiert: Abdur Rob am 25 Sep. 2020
function too_young = under_age(age, limit)
if age < limit
too_young = true;
else
too_young = false;
return
end
if age < 21
too_young = true;
end

Akzeptierte Antwort

madhan ravi
madhan ravi am 25 Sep. 2020
Since you have shown efforts:
too_young = under_age(2, []) % [] means no limit was given
function too_young = under_age(age, limit)
if isempty(limit)
limit = 21;
else
limit = limit;
end
too_young = age < limit;
end
  3 Kommentare
madhan ravi
madhan ravi am 25 Sep. 2020
function too_young = under_age(varargin)
if nargin < 2
age = varargin{1};
limit = 21;
else
age = varargin{1};
limit = varargin{2};
end
too_young = age < limit;
end
Abdur Rob
Abdur Rob am 25 Sep. 2020
thank you sir for your constractive support

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Argument Definitions finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by