Skip to content

(English) If and While

Luxs710 edited this page Mar 1, 2023 · 4 revisions

Conditional control structure (if)

você quer ser tudo, <x> e não é de nada

When using the command você quer ser tudo \<x\>, the code between você quer ser tudo and e não é de nada is only executed if the numeric value of x is 1

Example:

Chico is the brother
Chico vale 80
Birina is the brother
Birina vale 40

maior is the brother
maior what is the brother, Chico ou Birina?

você quer ser tudo, maior
Melancia is the sister
Melancia disse: Chico é maior do que birina
Melancia respondeu
e não é de nada

Melancia will only print it's content if Chico > Birina

Eu não vou parar de mesclar / enquanto <x> assim continuar (do while)

The program will execute the code between eu não vou parar de mesclar and enquanto \<x\> assim continuar, while the numeric value of x is equals 1

it behaves like a do while

Example:

Chico is the brother
Chico vale 5
Um is the brother
Um vale tudo
Continuar is the brother
Continuar, what is the brother, Chico ou Um?

eu não vou parar de mesclar
Chico respondeu
Chico, entre Chico e um, qual é a diferença?
Continuar, what is the brother, Chico ou um?
enquanto Continuar assim continuar

starts with Chico = 5 and every time the loop runs, it subtracts 1 from the variable Chico, until it gets to 0

each time the loop runs, the value of Chico is printed in the screen

Clone this wiki locally