If Rand 0.5 Disp ( It Was Less Than .5!') Else Disp ( It Was Not Less Than .5!') End
If Rand 0.5 Disp ( It Was Less Than .5!') Else Disp ( It Was Not Less Than .5!') End
5
disp(‘It was less than .5!’)
else
disp(‘It was not less than .5!’)
end
a =input('value of a:');
b = input('value of b:');
% check the boolean condition
if( a == 100 )
end
fprintf('Exact value of a is : %d\n', a );
fprintf('Exact value of b is : %d\n', b );
a = 100;
%check the boolean condition
if a == 10
% if condition is true then print the following
fprintf('Value of a is 10\n' );
elseif( a == 20 )
% if else if condition is true
fprintf('Value of a is 20\n' );
elseif a == 30
% if else if condition is true
fprintf('Value of a is 30\n' );
else
% if none of the conditions is true
fprintf('None of the values are matching\n');
fprintf('Exact value of a is: %d\n', a );
end
switch <switch_expression>
case <case_expression>
<statements>
case <case_expression>
<statements> ... ...
otherwise <statements>
end
grade = input('grade : ');
switch(grade)
case 'A'
fprintf('Excellent!\n' );
case 'B'
fprintf('Well done\n' );
case 'C'
fprintf('Well done\n' );
case 'D'
fprintf('You passed\n' );
case 'F'
fprintf('Better try again\n' );
otherwise
fprintf('Invalid grade\n' );
end