a=input('enter number'); b=input('enter number'); c=input('enter operator'); switch c case'+' disp(a+b); case'-' disp(a-b); end
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponses (2)
James Tursa
le 30 Avr 2015
Input variable c as a string. E.g.,
c = input('enter operator','s')
3 commentaires
Kelvin Viroja
le 22 Août 2016
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);
0 commentaires
Voir également
Catégories
En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!