### Teorija

Sarežģītākas Boolean tipa izteiksmes
Izmantojot operācijas not, or, and un xor, var izveidot sarežģītākas Boolean tipa izteiksmes.

Piemērs:
 $\phantom{\rule{0.147em}{0ex}}\left(x<10\right)\phantom{\rule{0.147em}{0ex}}\mathbf{and}\phantom{\rule{0.147em}{0ex}}\left(x>0\right)\phantom{\rule{0.147em}{0ex}}$
Šīs izteiksmes vērtība būs True tikai tad, ja x ir vienlaikus mazāks par 10 un lielāks par 0.

 $\phantom{\rule{0.147em}{0ex}}\left(\mathbf{Vaards}=\text{'}\mathrm{Janis}\text{'}\right)\phantom{\rule{0.147em}{0ex}}\mathbf{or}\phantom{\rule{0.147em}{0ex}}\left(\mathbf{Vaards}=\text{'}\mathrm{Andris}\text{'}\right)\phantom{\rule{0.147em}{0ex}}$
Šeit vērtība būs True tikai tad, ja Vaards vērtība ir 'Janis' vai 'Andris'.

 $\phantom{\rule{0.147em}{0ex}}\left(n\phantom{\rule{0.147em}{0ex}}\mathbf{mod}\phantom{\rule{0.147em}{0ex}}2=0\right)\phantom{\rule{0.147em}{0ex}}\mathbf{xor}\phantom{\rule{0.147em}{0ex}}\left(n\phantom{\rule{0.147em}{0ex}}\mathbf{mod}\phantom{\rule{0.147em}{0ex}}3=0\right)\phantom{\rule{0.147em}{0ex}}$
True sanāks tikai tad, ja n dalīsies vai nu ar 2, vai arī ar 3 (bet ne ar abiem reizē).

Un šādas izteiksmes var izmantot kā nosacījumus if...then sazarojumos.

Piemērs:
 $\begin{array}{l}\phantom{\rule{0.147em}{0ex}}\mathbf{if}\phantom{\rule{0.147em}{0ex}}\left(n\phantom{\rule{0.147em}{0ex}}\mathbf{mod}\phantom{\rule{0.147em}{0ex}}7=0\right)\phantom{\rule{0.147em}{0ex}}\mathbf{and}\phantom{\rule{0.147em}{0ex}}\left(n\phantom{\rule{0.147em}{0ex}}\mathbf{mod}\phantom{\rule{0.147em}{0ex}}2=1\right)\phantom{\rule{0.147em}{0ex}}\mathbf{then}\\ \phantom{\rule{0.147em}{0ex}}\phantom{\rule{0.147em}{0ex}}\phantom{\rule{0.147em}{0ex}}\mathbf{writeln}\left(\text{'}\mathrm{Sis}\phantom{\rule{0.147em}{0ex}}\mathrm{ir}\phantom{\rule{0.147em}{0ex}}\mathrm{nepara}\phantom{\rule{0.147em}{0ex}}\mathrm{skaitlis},\phantom{\rule{0.147em}{0ex}}\mathrm{kas}\phantom{\rule{0.147em}{0ex}}\mathrm{dalas}\phantom{\rule{0.147em}{0ex}}\mathrm{ar}\phantom{\rule{0.147em}{0ex}}7\text{'}\right);\phantom{\rule{0.147em}{0ex}}\end{array}$

 $\begin{array}{l}\phantom{\rule{0.147em}{0ex}}\mathbf{if}\phantom{\rule{0.147em}{0ex}}\left(\mathrm{Username}=\text{'}\mathbf{Janis}\text{'}\right)\phantom{\rule{0.147em}{0ex}}\mathbf{and}\phantom{\rule{0.147em}{0ex}}\left(\mathrm{Password}=\text{'}\mathrm{aizverlogu}\text{'}\right)\phantom{\rule{0.147em}{0ex}}\mathbf{then}\phantom{\rule{0.147em}{0ex}}\\ \phantom{\rule{0.147em}{0ex}}\phantom{\rule{0.147em}{0ex}}\phantom{\rule{0.147em}{0ex}}\mathbf{writeln}\left(\text{'}\mathrm{Deriga}\phantom{\rule{0.147em}{0ex}}\mathrm{kombinacija}\text{'}\right)\\ \phantom{\rule{0.147em}{0ex}}\mathbf{else}\\ \phantom{\rule{0.147em}{0ex}}\phantom{\rule{0.147em}{0ex}}\phantom{\rule{0.147em}{0ex}}\mathbf{writeln}\left(\text{'}\mathrm{Nederiga}\phantom{\rule{0.147em}{0ex}}\mathrm{kombinacija}\text{'}\right);\end{array}$

 $\begin{array}{l}\phantom{\rule{0.147em}{0ex}}\mathbf{if}\phantom{\rule{0.147em}{0ex}}\left(x=0\right)\phantom{\rule{0.147em}{0ex}}\mathbf{or}\phantom{\rule{0.147em}{0ex}}\left(y=0\right)\phantom{\rule{0.147em}{0ex}}\mathbf{or}\phantom{\rule{0.147em}{0ex}}\left(z=0\right)\phantom{\rule{0.147em}{0ex}}\mathbf{then}\phantom{\rule{0.147em}{0ex}}\\ \phantom{\rule{0.147em}{0ex}}\phantom{\rule{0.147em}{0ex}}\phantom{\rule{0.147em}{0ex}}\mathbf{writeln}\left(\text{'}\mathrm{Reizinajums}\phantom{\rule{0.147em}{0ex}}\mathrm{ir}\phantom{\rule{0.147em}{0ex}}0\text{'}\right)\\ \phantom{\rule{0.147em}{0ex}}\mathbf{else}\\ \phantom{\rule{0.147em}{0ex}}\phantom{\rule{0.147em}{0ex}}\phantom{\rule{0.147em}{0ex}}\mathbf{writeln}\left(\text{'}\mathrm{Reizinajums}\phantom{\rule{0.147em}{0ex}}\mathrm{nav}\phantom{\rule{0.147em}{0ex}}0\text{'}\right);\end{array}$