Tuesday, 19 August 2014

Continue Statement

//Program for Continue statement

import java.io.*;
import java.io.*;
class Continue
{
    public static void main(String s[]) throws Exception
    {
        int n,i;
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        System.out.print("\nEnter n:");
        n=Integer.parseInt(br.readLine());

        System.out.print("\nOdd Numbers: ");
        for(i=0;i<=n;i++)
        {
            if(i%2==0)
            {
                continue;
            }
            else
            {
                System.out.println("\n"+i);
            }
        }
    }
}
Output
Enter n:10

Odd Numbers:
1

3

5

7

9

No comments:

Post a Comment