"Program scope not closed properly." in pseudocode

Asked

Viewed 3,755 times

1

I wrote the following pseudocode only that I am receiving the following error: The program scope has not been closed properly. enter the character '}' to fix the problem. I have tried to close with the '}' only it ends up generating more mistakes, someone could help me?

programa
{ Var cont, somatoria: inteiro
    funcao inicio()
    { cont ← 0 
        para cont ← 1 Ate 100 Faca 
            soma ← soma + cont 
            cont ← cont + 1
        fim para
        escreva "A somatoria é: ", soma 
    }
}

3 answers

6

You have a fim para remaining, put him out

programa
{ 
    Var cont, somatoria: inteiro
    funcao inicio()
    { 
        cont ← 0 
        para cont ← 1 Ate 100 Faca 
           soma ← soma + cont 
           cont ← cont + 1
        fim para
        escreva "A somatoria é: ", soma
    }
    fim para //apague essa linha
    escreva "A somatoria é: ", soma //essa linha está repetida, seria isso proposital?
}

It is always important to correctly identify your code, so you avoid this kind of silly error. Notice the space I put before each line making the code much more readable.

EDITION

You wrote your program in pseudo-code, however the Portugol has a well-defined syntax of programming, a correct example of loop repetition for would be:

para(inteiro i=0; i<qtd; i++) {
    escreva("i vale", i)
}

Among several other details you passed beaten, for example the statement of variables should be:

inteiro cont, somatoria
  • I had tested again and ended up forgetting this part but the error has nothing to do with this line.

  • 2

    @matheusferreira Are you sure about this? If yes, you could then update your code and your error?

  • error is on line 2 . same error as in editing.

  • no, I already deleted what was repeating the error this in a part using the { e this saying that is not closing properly to close use the } more I tried.

  • @matheusferreira am downloading this tool

  • @matheusferreira the sitaxe of the commands is completely different from what you wrote

  • Could you be any clearer? I kind of tested this program and I’m thinking of testing on another could indicate me a reliable to write this code without even a kind of error?

  • @matheusferreira take a look at this video here

  • 1

    @matheusferreira please see my EDITION

Show 4 more comments

4

There is an end to before the last write

1


I believe that the syntax does not correspond to traditional English

programa
{   
    funcao inicio()
    {
        inteiro cont
        inteiro somatoria
        inteiro soma

        cont = 0
        somatoria = 0
        soma = 0

        para (cont = 1; cont < 10; cont++)
        {
               soma = soma + cont 
               cont = cont + 1
        }         
        escreva ("A somatoria é: ", soma)       
    }
}

Website: Portugolstudio

  • until the time is right more precise make it disappear in the range of 1 until 10 and have to be integers.

  • Just remembering that the sum has already been made in the example!

Browser other questions tagged

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