CHAMP3333 - 1 year ago 242

Java Question

I get in next code:

`class Divisible {`

public static void main(String args[]) {

int number[]=new int[200];

int i,sum=0;

for(i=0;i<number.length;i++) {

number[i]=i;

}

for(i=0;i<number.length;i++) {

if((number[i]>100) && (number[i]<200) && (number[i]/7)) {

sum=sum+number[i];

}

}

System.out.println("Sum =" +sum);

}

}

Answer Source

It is quite clear - && is a binary operator and you need to use a boolean operand for it.

Here:

```
if((number[i]>100) && (number[i]<200) && (number[i]/7))
```

`(number[i]/7)`

is a number, and it does not qualify to be an operand of && operator.