Say me pls about "n /= 10;". What is it and what it make in my code?
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
while (n > 0)
{
if (n % 2 == 0)
even++;
else
odd++;
n /= 10;
}
System.out.print("Even: " + even + " Odd: " + odd);
WHAT IS IT "N /= 10;"?
Under discussion
Comments (4)
- Popular
- New
- Old
You must be signed in to leave a comment
Dona
8 July 2019, 12:32
I have also this doubt. can someone explain this ?
0
Zserbo
12 June 2019, 20:58
The /= operator is similar to the += and -= operators. It divides n by 10 and puts the result in the variable n.
is basically
This way you can iterate through each of the characters in the n variable. +1
Denis
13 June 2019, 09:38
Why do we use this division?
0
Hoang Khai
11 July 2019, 02:26
to make the number smaller until it becomes 0(this time, the loop will end).
0