"Program scope was not closed properly." in pseudocode

1

I wrote the following pseudocode only I am getting the following error: The program scope was not closed properly. enter the '}' character to correct the problem. I already tried to close with '}' only it ends up generating more errors, could anyone 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 
    }
}
    
asked by anonymous 10.04.2014 / 16:54

3 answers

1

I think the syntax does not match the traditional Portuguese

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)       
    }
}

Site: PortugolStudio

    
10.04.2014 / 17:33
6

You have a fim para over, delete it

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's always important to properly indentify your code, so you avoid this kind of silly mistake. Notice the space I put before each line making the code much more readable.

EDITION

You have written your program in pseudo-code, however Portugol has a well-defined programming syntax, an example Correct repeat loop for would be:

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

Among several other details that you passed beat, such as the variable declaration should be:

inteiro cont, somatoria
    
10.04.2014 / 16:59
4

There is an end before the last write

    
10.04.2014 / 16:59