フィルターのクリア

a=input('enter number'); b=input('enter number'); c=input('enter operator'); switch c case'+' disp(a+b); case'-' disp(a-b); end

2 ビュー (過去 30 日間)
waqas khosa
waqas khosa 2015 年 4 月 30 日
回答済み: Kelvin Viroja 2016 年 8 月 22 日
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
James Tursa 2015 年 4 月 30 日
Input variable c as a string. E.g.,
c = input('enter operator','s')
  3 件のコメント
James Tursa
James Tursa 2015 年 4 月 30 日
Have you tried it?
waqas khosa
waqas khosa 2015 年 4 月 30 日
no will tried it tomorrow in uni here setup is not running ...due to lisence key or something else.. i dont have more concern about it because i m engineering student.. not CS or related to this,,,

サインインしてコメントする。


Kelvin Viroja
Kelvin Viroja 2016 年 8 月 22 日
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);

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by