ICSE Class 10 Computer Applications
Question 17 of 43
Conditional Constructs in Java — Question 17
Back to all questions 17
Question Question 17
Write a program to find the number of and sum of all integers greater than 500 and less than 1000 that are divisible by 17
public class KboatDivisibleBy17
{
public static void main(String args[]) {
int sum = 0, count = 0;
for (int i = 501; i < 1000; i++) {
if (i % 17 == 0) {
count++;
sum += i;
}
}
System.out.println("Sum = " + sum);
System.out.println("Count = " + count);
}
}Output
