a=input('enter number'); b=input('enter number'); c=input('enter operator'); switch c case'+' disp(a+b); case'-' disp(a-b); end
이전 댓글 표시
a=input('enter number');
b=input('enter number');
c=input('enter operator');
switch c
case'+'
disp(a+b);
case'-'
disp(a-b);
end
guyzz in this program i dnt knw about operator and second there is an error of operator.. make this progarm true and also from this switch statement..nor other.thak u.
답변 (2개)
James Tursa
2015년 4월 30일
Input variable c as a string. E.g.,
c = input('enter operator','s')
댓글 수: 3
waqas khosa
2015년 4월 30일
James Tursa
2015년 4월 30일
Have you tried it?
waqas khosa
2015년 4월 30일
Kelvin Viroja
2016년 8월 22일
0 개 추천
U can easily do it by using if loop
a=input('enter number'); b=input('enter number'); c=input('enter operator','s'); d='+'; e='-';
if strcmp(c,d) G=a+b; else if strcmp (c,e) G=a-b; else end
disp(G);
카테고리
도움말 센터 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!