1 / 10

Case Anweisung

Case Anweisung. Case <Selector> of Wert1:Anweisung1 Wert2:Anweisung2 ………………… Wertn:Anweisung n [Else Anweisung] End;. Beispiele:. Var i:integer; Begin readln(i); case i of 1:write(‘Einz’); 2:write(‘Zwei’); 3:write(‘Drei’);

zihna
Download Presentation

Case Anweisung

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 Anweisung Case <Selector> of Wert1:Anweisung1 Wert2:Anweisung2 ………………… Wertn:Anweisung n [Else Anweisung] End;

  2. Beispiele: Var i:integer; Begin readln(i); case i of 1:write(‘Einz’); 2:write(‘Zwei’); 3:write(‘Drei’); else write(‘Andere Zahl’); end; End.

  3. Wiederholungsanweisungen

  4. Welche sind diese? • Mit Abbruchsbedingung am Anfang • Mit Abbruchsbedingung am Ende • Mit Zahler

  5. In pascal: • While-Do • Repeat-Until • For-Do

  6. While- Do • Struktur While <Logischer Ausdruck> do Anweisung

  7. Beispiel S=1+2+3+4+5 Var s,i:integer; Begin s:=0; i:=1; while i<=5 do Begin s:=s+i; i:=i+1; end; write(s); End.

  8. Löst selbst! • S=1+2+…+n • S=1+1/2+…+1/n

  9. Repeat-until Struktur Repeat Anweisung Until <Logischer Ausdruck>

  10. Beispiel • S=1+2+3+4+5 Var s,i:integer; begin S:=0; i:=1; repeat s:=s+i; i:=i+1 until i>n; write(s) End.

More Related