Numberlist with Visualg

Asked

Viewed 169 times

4

Problem with this algorithm in visualg The code is making infinite loop "Numberlist"

// Função :

// Autor :

// Data : 09/02/2016

// Seção de Declarações 

var

a1,b1,c1:inteiro

inicio

// Seção de Comandos 



    para a1 de 0 ate 9 faca

    para b1 de 0 ate 9 faca

    para c1 de 0 ate 9 faca



a1 := 0

b1 := 0

c1 := 0


escreva

("a1","b1","c1")

    fimpara

    fimpara

    fimpara


 fimalgoritmo
  • 1

    Hello Joa. I reopened the question, but the format "find the error in the code" I still find a little strange - it’s more of a challenge than a question. If this code generates an error message, or generates an incorrect output, citing it would be a more interesting path. For example: "My algorithm should produce an output thus, but it’s generating a way out roasted. What’s going on?". You don’t even need to edit this one (especially since it was well received), but consider this for your next posts. And welcome to the site :)

  • thanks for the feedback @bfavaretto !

1 answer

3


I found it! 1° The variables have values declared within the " for knife". In any code this makes the loop infinite.

2° In "write(.)" the variables are written in quotation marks. What characterizes the variables as text, contrary to the statement of variables as "integer"

The code of the correct form would be this way

// Função : 

// Autor :

 // Data : 09/02/2016 

// Seção de Declarações 

var 

a1,b1,c1:inteiro

 inicio 

// Seção de Comandos


 a1 := 0

 b1 := 0 

c1 := 0 

 para a1 de 0 ate 9 faca

 para b1 de 0 ate 9 faca 

para c1 de 0 ate 9 faca


escreva

(a1,b1,c1)

fimpara

 fimpara 

fimpara 

fimalgoritmo

:v

  • I reworked the post and the answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.