Program of Ifelse statement in Java

Free Java Programs

Program of Ifelse statement

class IfElseTest
{
public static void main((String args[])
{
int number[]={50,65,56,71,81);
int even=0;odd=0;
for(int i=0;i
{
if((number [i]%2)= =0) //decide even or odd
{
even+=1; // counting even numbers
}
else
{
odd+=1; // counting ODD numbers
}
}
System.out.println(“Even Numbers:”+even+””ODD Numbers:”+Odd);
}
}

Output:
Even numbers:2 Odd numbers:3

Post a Comment

Previous Post Next Post