This code prints the odd numbers in a given range.
Java Code
public class oddNumber {
public static void main(String[] args) {
int from = 1;
int to = 10;
for(int i = from; i <= to; i++) {
if(i % 2 != 0) {
System.out.print(i + "\n");
}
}
}
}
Output
1
3
5
7
9