number even, odd, zero and greater than 10 how to find it? [duplicate]

0
For g = 1 To 10
For f = 1 To 10

  Cells(f, g) = Int(100 * Rnd())
  k = Cells(f, g)

 If Int(k / 2) - k / 2 = 0 Then

        pares = pares + 1

    Else

        Impares = Impares + 1

    End If

    If k = 0 Then Zeros = Zeros + 1

    If k > 10 Then MaioresQuedez = MaioresQuedez + 1


Cells(12, 2) = pares & " números Pares"

Cells(14, 2) = Impares & " números Ímpares"

Cells(16, 2) = Zeros & " números Zero"

Cells(18, 2) = MaioresQuedez & " números maiores do que 10"


Next f
Next g
    
asked by anonymous 09.07.2016 / 19:48

1 answer

1

As an example, I used only the variable K, you can do the same for other variables, if applicable.

Before the "loop" zeros the variables "

Pares = 0

Impares = 0

Zeros = 0

MaioresQueDez = 0

Put this inside the loop and / or adapt to other variables:

    If Int(K/2) - K/2 = 0 then 

        Pares = Pares + 1 

    Else 

        Impares = Impares + 1 

    End If

    If K = 0 Then Zeros = Zeros + 1

    If K > 10 Then MaioresQueDez = MaioresQueDez + 1

09.07.2016 / 20:56