create a calculator using arithmetic operators

a=input(prompt,'s');
c=2;
d=3;
h=6;
if a=='+'
e=c+d;
e
else
e=c-d;
e
end
what is wrong with this addition code?

 采纳的回答

prompt = 'Enter sign:' ;
a=input(prompt,'s');
c=2;
d=3;
h=6;
if strcmp(a,'+')
e=c+d;
e
else
e=c-d;
e
end

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Entering Commands 的更多信息

产品

版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by