2
My code below represents the scenario of keeping a feedback of 5 questions, where:
- Each question is worth 2 points
- Check if 3 students will hit the Feedback
- Calculate Each Student’s Individual Grade
- Calculate the Class Average
My question is right there in the addition of student grades, more specifically in this expression: soma <- soma + 2
.
The sum "unites" the values of nota[a]
, but I did not put the value in the sum to receive the same.
- a) Why this happens?
- b) Because this place uses the
+ 2
?. - c) The note[a] vector would actually hold a value?
The Place of Doubt:
nota[a] <- nota[a] + 2
soma <- soma + nota[a]
My Code:
Var i,a,c: inteiro
resp,gab: vetor[1..5] de caractere
nome: vetor[1..3] de caractere
nota: vetor[1..5] de real
m,soma: real
Inicio
Para i <- 1 ate 5 faca
Escreva("Digite o gabarito ", i)
Leia(gab[i])
FimPara
Para a <- 1 ate 3 faca
EscrevaL("ALUNOS ", a)
Escreva("Nome: ")
Leia(nome[a])
Para c <- 1 ate 5 faca
Escreva("Digite a questão ", c)
Leia(resp[c])
Se (gab[i]=resp[c]) entao
EscrevaL(" acertou a ", c)
nota[a] <- nota[a] + 2
soma <- soma + 2
FimSe
FimPara
m <- soma/3
FimPara
Para a <- 1 ate 3 faca
EscrevaL(nome[a]: 10, nota[a])
FimPara
Escreva("Média da Turma: ", m)
Welcome Ale, is this your code? Could you edit the ask and put the exercise? Or comment on the main lines of the code? I’d make it easier to help you
– Luiz Augusto
Luiz, see if it’s easy to understand my doubt now. Please, if it’s not clear tell me that I edit again.
– Ale D.
It was clear, yes, alias I’m tampering with your code now, I already have some answers to your questions, the problem is that the comparison
gab[i]=resp[c]
is returning false and I am not getting into the sum loop, you are managing to perform this part?– Luiz Augusto
Here it’s working, yeah.
– Ale D.
I’ll clear your doubts
– Luiz Augusto