Finding odd numbers in between 15-27 in Java

This program is used to find an odd numbers in between 15-27.Here we are using For loop and if condition.For loop is used to iterating the values and if condition is used to checking the conditions.

Source code :

public class ExampleFindOdd{
    public static void main(String args[]){  

     for(int i=15; i <= 27; i++){
                       
                        if( i % 2 == 1){
                                System.out.print(i + " ");
                        }
    }
}

Output :

15,17,19,21,23,25,27

Output :


                

Comments :