#### Total Even Odd coderinme

Total Even Odd

Given any number, when it is divided by 2, should give either a remainder 0 or 1. If the remainder is 0, then it is even, If remainder is 1 then it’s odd. In simpler words, An even number is an integer that is exactly divisible by 2. Example: 8, 34, 0. An odd number is an integer that is not exactly divisible by 2. Example: 1, 7, 11, 15

So, if a number is x and then rem(x/2)==0 or x%2==0 then it is even else odd

So let’s code to Write a java program to prints the count of odd and even no’s entered.

Program:

```
import java.io.*;
public class Q2
{
public static void main(String[] args) throws IOException
{
BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
int even=0, odd=0, i;
System.out.print(" Enter a positive intger: ");
int a = Integer.parseInt(inp.readLine());
for(i=1; i<=a;i++)
{
if(i%2==0)
even++;
else
odd++;
}
System.out.println(" Total number of even number is: "+even);
System.out.println(" Total number of odd number is: "+odd);
}
}
```

For more programs on Java, visit our Java Archives

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme