Q:

Calculate Sum Of Numbers That Are Divisible By 8 Of First 100 Natural Numbers Using Java

0

Calculate Sum Of Numbers That Are Divisible By 8 Of First 100 Natural Numbers Using Java

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

// Sum of numbers that are divisible by 8 of first 100 natural nos 

class ssvsumnat1 
{ 
public static void main(String args[]) 
{ 
int sum = 0; 
System.out.println("\n\n\tSum of numbers that are divisible by 8 of first 100 natural nos"); 
System.out.print("\t******************************************************"); 
for(int i=1;i<=100;i++) 
{
if(i%8 == 0) 
sum = sum + i; 
}
System.out.println("\n\n\t\tSUM = " + sum); 
} 
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now