QuestionAsk Questions?

what will be the source code of the program that the output will be printing all numbers that is divisible by 3 and 5

sample output: 3 is divisible by 3 5 is divisible by 5 6 is divisible by 3 9 is divisible by 3 10 is divisible by 5 12 is divisible by 3 15 is divisible by 3 15 is divisible by 5

View Answers

February 23, 2012 at 3:37 PM

class NumberDivisible { public static void main(String[] args){ for( int i=1; i<=100; i++) { if(i%3==0){ System.out.println(i+" is divisible by 3"); } if(i%5==0){ System.out.println(i+" is divisible by 5"); } } } }

Related Tutorials/Questions & Answers: