wap to add even and odd numbers of an array
Answers
Answered by
0
class x
{
public void cal(int a[])
{
int s1=0,s2=0;
for(int i=0;i<=10;i++)
{
if(a[i]%2==0)
s1+=a[i];
else
s2+=a[i];
}
System.out.println("sum of even=+s1);
System.out.println("sum of odd=+s2);
}
}
{
public void cal(int a[])
{
int s1=0,s2=0;
for(int i=0;i<=10;i++)
{
if(a[i]%2==0)
s1+=a[i];
else
s2+=a[i];
}
System.out.println("sum of even=+s1);
System.out.println("sum of odd=+s2);
}
}
Similar questions