Page 221 - CA_Blue( J )_Class9
P. 221
Write a program to enter "n" numbers and print all those numbers that are divisible by 2
Program 10
and 5.
1 import java.util.*;
2 class prog_loop2
3 {
4 public static void main()
5 {
6 Scanner sc = new Scanner (System.in);
7 int n, no, c=0, i ;
8 System.out.println("Enter n : ");
9 n=sc.nextInt ();
10 for (i = 1; i <= n; i++)
11 {
12 System.out.print("Enter a number : ");
13 no = sc.nextInt ();
14 if (no % 2 == 0 && no % 5 == 0)
15 {
16 System.out.println(no + "is divisible by 2 and 5");
17 }
18 }
19 }
20 }
You will get the following output:
Iterative Constructs in Java 219

