-1
I can’t understand when to use one or the other. in this code, I used both forms and saw no change at the end. What’s the difference and when to use one or the other
Create a procedure that receives two values per reference and sort them in ascending order. Create a main algorithm to call the procedure and display values after ordering.
Algoritmo "procedimento"
Var
x, y: inteiro
Procedimento crescente(var A,B: inteiro)
var
cres: inteiro
inicio
Se (a < b) entao
para cres de a ate b faca
Escreva(cres)
cres <- cres + 1
fimpara
Senao
para cres de b ate a faca
Escreva(cres)
cres <- cres + 1
fimpara
Fimse
FimProcedimento
Inicio
x <- 10
y <- 20
crescente(x, y)
Fimalgoritmo
Thank you, it’s a bit confusing for me. Actually a lot. I will run this code, let’s say if I take the var, to see what happens
– Allan Maximo
Not at all! If you take the VAR the parameter becomes by value. The VAR that defines parameter by reference. In the beginning it is so, it has to persist, because with the practice it learns.
– Anderson Salles