IF else stement with Logical OR operator problem
Show older comments
I was writing a program use logical OR operator in If else . I used following code:-
grade=input('enter grade of the student \n', 's');
if grade=='A'|'B'
fprintf('student''s grade is %c. excellent Job \n',grade);
elseif grade=='C'
fprintf('student''s grade is %c. well done \n',grade);
elseif grade=='D'
fprintf('student''s grade is %c. Try harder\n',grade);
else
fprintf('Invalid entry\n');
end
irrespective of what is enter, always it shows " student's grade is X . excellent Job". Matlab is not processing any else if conditions.
Kindly provide insight
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!