Write a program in Java to print odd no.s from 1 to 100.
Answers
Answered by
3
Answer:
import java.util.*;
class OddNumber
{
public static void main(String args[])
{
System.out.println("The Odd Numbers are:");
for (int i = 1; i <= 100; i++)
{
if (i % 2 != 0)
{
System.out.print(i + " ");
}
}
}
}
Hope this helps you.
Answered by
0
//java program using for loop
import java.io.*;
public class Odd
{
public static void main (String args [])
{
for(i=1, i<=100, i++)
{
if(i%2 !=0)
{
System.out.println("Odd numbers" "+i);
}
}
}
}
Similar questions
Math,
6 months ago
Math,
6 months ago
English,
6 months ago
Social Sciences,
1 year ago
English,
1 year ago