IF else stement with Logical OR operator problem
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Spreadsheets en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!