Even or Odd Program without using modules%

August
11

Posted By:pradeeshtet

Comments:
0

Let us see a java program finding even or odd without using modules operator. Frequent Interview question in technical or programming round. Programming languages C#(sharp), python,php, c, c++,java.Even number is a number, which is divisible by two, rest of the numbers are odd numbers.

c=number-(number/2)*2;
Let's check 51 is even or not
c= 51-(51/2)*2;
51 divide by 2 (51/2) will give 25 as quotient
c = 51-(25)*2
c = 51-50
c = 1
c=1, therefore we found that the given number 51 is an odd number

Example 2: number=40
c=number-(number/2)*2;
c= 40-(40/2)*2;
40 divide by 2 (40/2) will give 20 as quotient
c = 40-(20)*2
c = 40-40
c = 0
c=0, therefore we found that the given number 40 is an even number.

Even or odd programs are also widely asked in interview for fresher, slightly in different format by different top mnc companies. Basic java program asked in interview: