Calculation of Sobra VISUALG

Asked

Viewed 142 times

0

Good evening, Colleagues!

I have this problem and I cannot find a solution even in the IDE documentation. I’d like to know which command to use to pick up the leftover division to use it in the instructions below it. I know basically that the command is MOD OR % just don’t know how to use it within the formula.

var

N,N2,N3,N4,N5,N6,N7: INTEGER

beginning

  Leia(N)
  N2 <- N/100 % 100
  Escreval (N2)
  Escreval //Quero usar a sobra da divisão aqui em baixo para outra conta, imaginando que o valor da variável N1 é 576 

fimalgoritmo

  • N2 <- N % 100 will assign to the N2 variable the rest of the division of N by 100. What you did is not much sense.

  • So thinking a lot here, it was meaningless! But I managed to put in the answer

1 answer

0


Stayed like this:

algoritmo "EXERCICIO 18"

var N,N2,N3,N4,N5,N6,N7,N8: INTEGER

beginning

  Leia(N)
  N2 <- N % 100
  ESCREVAL (N/100 MOD 100," nota(s)", " de", " R$ ", "100,00")
  N3 <- N2 % 50
  ESCREVAL (N2/50 MOD 50," nota(s)", " de", " R$ ", "50,00")
  N4 <- N3 % 20
  ESCREVAL (N3/20 MOD 20," nota(s)", " de", " R$ ", "20,00")
  N5 <- N4 % 10
  ESCREVAL (N4/10 MOD 10," nota(s)", " de", " R$ ", "10,00")
  N6 <- N5 % 5
  ESCREVAL (N5/5 MOD 5," nota(s)", " de", " R$ ", "5,00")
  N7 <- N6 % 2
  ESCREVAL (N6/2 MOD 2," nota(s)", " de", " R$ ", "2,00")
  N8 <- N7 % 1
  ESCREVAL (N7/1," nota(s)", " de", " R$ ", "1,00")

fimalgoritmo

  • I think you should take a look at the meaning of the operator rest of the division (MOD or %).

Browser other questions tagged

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