In: Computer Science
1. Consider an arithmetic expression of the form a#b=c. Check whether it is possible to replace with one of the four signs: +, -, * or / to obtain a correct expression.
Test Sample |
a |
b |
c |
Expected Output |
1 |
2 |
3 |
5 |
True |
2 |
8 |
2 |
4 |
True |
3 |
8 |
3 |
2 |
False |
4 |
6 |
3 |
3 |
True |
5 |
5 |
2 |
0 |
False |
6 |
10 |
2 |
2 |
False |
Make a MATLAB program
RAW CODE (FOR BOOLEAN OUTPUT)
function val = myfunc(a,b,c)
if (a+b == c || a-b == c || a/b == c || a*b == c)
val = true;
else
val = false;
endif
endfunction
y = myfunc(4,2,2)
NOTE:- THIS WILL RETURN OUTPUT IN THE FORM OF 0 (FALSE) AND 1 (TRUE).
SCREENSHOT (CODE AND OUTPUT)
RAW CODE (FOR STRING OUTPUT)
function val = myfunc(a,b,c)
if (a+b == c || a-b == c || a/b == c || a*b == c)
val = "True";
else
val = "False";
endif
endfunction
y = myfunc(4,2,2)
NOTE:- THIS WILL RETURN OUTPUT IN THE FORM OF STRING "TRUE" AND "FALSE".
SCREENSHOT (CODE AND OUTPUT)
CODE WITH COMMENTS
##### FOR ANY QUERY, KINDLY GET BACK, THANKYOU. #####