MATLAB Session-1 : Basic Operations Q1
QUESTION 1: Basic array vector Operations
Question Description:Take two inputs from the user as a and b and check the relationship between the two variables. 1. Depends on both the values using (AND operation) it should return "Both are non-zero or not". 2.Depends on both the values using (OR operation) it should return "Atleast one of the value is non-zero or not". 3. Depends on both the values using (NOT operation) it should return "Both values are non-zero and its negation is zero or not".
·
Test Case 1
Input
5
6
6
Output
Both are non-zero
Atleast one of the value is non-zero
Both values are non-zero and its negation is zero
·
Test Case 2
Input
0
Output
0
CODE MATHSLAB
a=input('');
b=input('');
if(a && b)
disp('Both
are non-zero');
else
disp('One
of the value is 0');
end;
if(a || b)
disp('Atleast
one of the value is non-zero');
else
disp('Both
values are zero');
end;
if(~(a && b))
disp('Both
values are zero and its negation is non-zero');
else
disp('Both
values are non-zero and its negation is zero');
end;
Comments
Post a Comment