IF B THEN A1 ELSE A2;
Tanlash operatorining quyidagi operatoriga ekvivalentdir:
CASE B OF
TRUE: A1;
FALSE: A2;
END;
Qisqa ko’rinishdagi shartli o’tish operatorining quyidagi ko’rinishi IF B THEN
A tanlash operatorining quyidagi ko’rinishga ekvivalentdir.
CASE B OF
TRUE: A;
FALSE: END;
Misol-1: Oylar nomlarini chop etish dasturi tuzilsin.
Dastur: PROGRAM WEEK(INPUT,OUTPUT);
VAR NUMBER: INTEGER;
BEGIN READ(NUNBER);
CASE NUMBER OF;
1: WRITELN (‘YANVAR’);
2: WRITELN (‘FEVRAL’);
3: WRITELN (‘MART’);
4: WRITELN (‘APREL’);
5: WRITELN (‘MAY’);
6: WRITELN (‘IYUN’);
7: WRITELN (‘IYO’L’);
8: WRITELN (‘AVGUST’);
9: WRITELN (‘SENTABR’);
10: WRITELN (‘OKTABR’);
11: WRITELN (‘NOYABR’);
12: WRITELN (‘DEKABR’);
END;
END.
Do'stlaringiz bilan baham: |