Problem: 2.16


Question 2.16:  Write a Java program to print the odd numbers from 1 to 99. Prints one number per line.

Sample Output:

1

3

5

....

97

99

Solution:


package com.company;
public class Lab2problem16 {
    public static void main(String[] args)
    {

        for(int i=1;i<100;i++)
        {
          if(i%2 != 00)
          {
              System.out.println(i);
          }
        }

    }
}

Previous Post Next Post