Page 170 - CA_Blue( J )_Class10
P. 170
Syntax of the continue statement is:
for (initialization; condition for testing; increment or decrement)
{
Statements inside loop;
if(condition)
{
continue;
}
Statements inside loop;
}
st
1 statement after loop;
Program 9 To input 5 numbers and print the product of the even numbers.
1 import java.util.*;
2 class product_even_number
3 {
4 public static void main()
5 {
6 Scanner sc= new Scanner(System.in);
7 int n,i=1,p=1;
8 while(i<=5)
9 {
10 System.out.print("Enter a number : ");
11 n=sc.nextInt();
12 if(n%2==1)
13 {
14 i++;
15 continue;
16 }
17 p=p*n;
18 i++;
19 }
20 System.out.println("Product of even numbers "+ p);
21 }}
You will get the following output:
168168 Touchpad Computer Applications-X

