Buscar

Evaluate the following program and choose the correct alternative: The program declares variables x and y with the values 0 and 1, respectively. T...

Evaluate the following program and choose the correct alternative:

The program declares variables x and y with the values 0 and 1, respectively.
The program reads an integer value from the standard input and stores it in the variable x.
The program enters a loop that multiplies the value of y by the value of x and decrements the value of x by 1 until x is less than or equal to 1.
The program prints the value of y on the screen.
a) For the input 3, the output will be 9.
b) For the input 2, the output will be 4.
c) For the input 5, the output will be 120.
d) For the input 4, the output will be 20.
e) For the input 4, the output will be 100.

Essa pergunta também está no material:

Linguagem e Técnica de Programação
16 pág.

Linguagem de Programação Estruturada Universidade PaulistaUniversidade Paulista

💡 1 Resposta

User badge image

Ed Verified user icon

A resposta correta é a alternativa c) Para a entrada 5, a saída será 120. Isso ocorre porque o programa realiza um loop em que o valor de y é multiplicado pelo valor de x e o valor de x é decrementado até que x seja menor ou igual a 1. No caso da entrada 5, o loop será executado 5 vezes, resultando em y = 1 * 2 * 3 * 4 * 5 = 120.

0
Dislike0

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você também pode ser Premium ajudando estudantes

✏️ Responder

SetasNegritoItálicoSublinhadoTachadoCitaçãoCódigoLista numeradaLista com marcadoresSubscritoSobrescritoDiminuir recuoAumentar recuoCor da fonteCor de fundoAlinhamentoLimparInserir linkImagemFórmula

Para escrever sua resposta aqui, entre ou crie uma conta

User badge image

Outros materiais

Outros materiais