1 / 6

Case … of …

Case … of …. grade?. grade = ‘F’. grade = ‘B’. grade = ‘A’. grade = ‘D’. display “very good”. display “good”. display “fair”. display “poor”. case grade of ‘A’ : writeln(‘very good’); ‘B’ : writeln(‘good’); ‘D’ : writeln(‘fair’); ‘F’ : writeln(‘poor’); end;.

Télécharger la présentation

Case … of …

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Case … of …

  2. grade? grade = ‘F’ grade = ‘B’ grade = ‘A’ grade = ‘D’ display “very good” display “good” display “fair” display “poor”

  3. case grade of ‘A’ : writeln(‘very good’); ‘B’ : writeln(‘good’); ‘D’ : writeln(‘fair’); ‘F’ : writeln(‘poor’); end;

  4. case <selector(integer/char/boolean)> of <case label 1> : <statement 1>; <case label 2> : <statement 2>; … <case label N> : <statement N>; end;

  5. Example 1 case number of 2,3,5,7 : numbertype:=‘prime’; 4,6,8,9,10 : numbertype:=not prime’; end;

  6. Example 2 case letter of ‘F’,’f’ : begin female:=female + 1; writeln(‘one female’); end; ‘M’,’m’:begin male:=male+1; writeln(‘one male’); end; end;

More Related