g. surgulaZe, g. janeliZe, i. xuciSvili
g. surgulaZe, g. janeliZe, i. xuciSvili
g. surgulaZe, g. janeliZe, i. xuciSvili
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
{<br />
}<br />
case 1: z=3*x-y; break;<br />
case 2: z=y-x; break;<br />
case 3: z=x+y; break;<br />
default: z=y;<br />
printf ("z=%d", z);<br />
Sesrulebis Sedegad daibeWdeba z=31. sxva x=10, y=20 sawyisi<br />
monacemebisTvis daibeWdeba z=10, xolo x=10, y=23 –sTvis daibeWdeba<br />
z=23. vnaxoT, rogor miiReba es Sedegebi.<br />
ganvixiloT pirveli SemTxveva (x=10, y=21). switch operatoris<br />
Sesruleba iwyeba mrgval frCxilebSi mocemuli gamosaxulebis<br />
gamoTvliT: y-2*x+2=21-20+2=3. miRebuli mniSvneloba Sedardeba case-<br />
ebis konstantebs manamde, sanam ar aRmoCndeba erT-erTi konstantis<br />
toli. Cvens SemTxvevaSi moxdeba 3-is Sedareba jer 1-Tan, Semdeg 2-Tan,<br />
bolos ki 3-Tan. rogorc ki toloba dafiqsirdeba, iwyeba Sesabamisi<br />
case-blokis operatorebis Sesruleba. Cvens SemTxvevaSi gamoiTvleba<br />
z=x+y; (z=31) da Sesruldeba operatori break. break – wyvetis operatori –<br />
uzrunvelyofs switch konstruqciidan gamosvlas. Semdeg Sesruldeba<br />
programis morigi operatori. Cvens fragmentSi es aris funqcia printf<br />
("z=%d", z);<br />
meore SemTxvevaSi (x=10, y=20) y-2*x+2= 20-20+2=2. marTva gadava case<br />
2: Semdeg mocemul operatorebTan: z=y-x => z=10, break; => gamosvla switch-<br />
idan. mere Sesruldeba printf ("z=%d", z); da daibeWdeba z=10.<br />
mesame SemTxvevaSi (x=10, y=23) y-2*x+2=23-20+2=5. radganac arc<br />
erTi konstanta ar aris 5-is toli, Sesruldeba default: blokis<br />
operatorebi, anu z=y; Semdeg ki funqcia printf ("z=%d", z); da daibeWdeba<br />
z=23.<br />
daSvebulia switch operatoris konstruqcia, romelic ar Seicavs<br />
rezervirebul sityvas default da Sesabamis operatorebis mimdevrobas.<br />
46