Buscar

What is the correct way to calculate the arithmetic mean of three grades in a program with multiple functions? The use of global variables is not ...

What is the correct way to calculate the arithmetic mean of three grades in a program with multiple functions?

The use of global variables is not recommended, as they can be accessed and have their value changed by any part of the program, making it difficult to understand.
It is recommended to communicate the grades to the calc_media function using parameters instead of global variables.
a) Only the first statement is correct.
b) Only the second statement is correct.
c) Both statements are correct.
d) Both statements are incorrect.

Essa pergunta também está no material:

Introducao_a_Progrmacao
103 pág.

Introdução à Programação Universidade Estácio de SáUniversidade Estácio de Sá

💡 1 Resposta

User badge image

Ed Verified user icon

A alternativa correta é a letra c) Ambas as afirmações estão corretas. É recomendado comunicar as notas para a função calc_media usando parâmetros em vez de variáveis globais, pois isso torna o programa mais legível e evita que as variáveis globais sejam acessadas e tenham seus valores alterados por qualquer parte do programa. Além disso, o cálculo da média aritmética pode ser feito somando as três notas e dividindo o resultado por 3.

0
Dislike0

✏️ 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