answersLogoWhite

0

It is actually quite easy to write a program in java to do this. The easiest way to do this that I can think of is to use the remainder operator (%) to test whether a number is odd or not. Here is a simple program that will print out all the odd numbers between 1 and 50.

public class OddNumbers {

public static void main(String[] args) {

int i=1;

while(i < 50) {

if(i%2 != 0) {

System.out.println(i);

}

i++;

}

}

}

User Avatar

Wiki User

16y ago

What else can I help you with?

Continue Learning about Engineering

What is the program to print odd number using for next loop in GE BASIC?

In GE BASIC, you can print odd numbers using a FOR-NEXT loop by specifying a starting point and incrementing by 2. Here’s a simple example: FOR I = 1 TO 99 STEP 2 PRINT I NEXT I This will print all odd numbers from 1 to 99. The STEP 2 ensures the loop only increments by 2, thereby producing only odd numbers.


What is odd loop?

Move the print out requesting the user to enter an integer outside of the for loop and it will only print once instead of each time around the loop. You'll need a way to save the even and odd numbers that you detect in the loop. One way is to have separate arrays to hold the even and the odd numbers as you go around the loop. Then at the end of the loop you can have more loops to print the contents of one array and then the contents of the other array. Another way is to concatenate the number onto separate Strings (even and odd) to be displayed after the data gathering loop.


How can you write a c program using while loop that will print first ten odd numbers?

#include&lt;stdio.h&gt; int main () { int odd=1; int count=0; while (count++&lt;10) { printf (%d\n", odd); odd+=2; } return 0; }


Write a program in shell script to display odd number from 0 to 100?

seq 1 2 99


How do you draw a Flowchart to find whether the given number is odd or even using counter?

first we write start and then read number and after that check the number is totaly divide by 2 or not if number is totally divide by 2 then number is even else number is odd.

Related Questions

Write a JavaScript for loop that will iterate from 0 to 15. For each iteration it will check if the current number is odd or even and display a message to Sample Output 0 is even 1 is odd 2 is even?

You can use the following JavaScript code to achieve this: for (let i = 0; i &lt;= 15; i++) { let message = `${i} is ${i % 2 === 0 ? 'even' : 'odd'}`; console.log(message); } This loop iterates from 0 to 15, checks if the current number i is even or odd using the modulus operator, and logs the appropriate message to the console.


What is the program to print odd number using for next loop in GE BASIC?

In GE BASIC, you can print odd numbers using a FOR-NEXT loop by specifying a starting point and incrementing by 2. Here’s a simple example: FOR I = 1 TO 99 STEP 2 PRINT I NEXT I This will print all odd numbers from 1 to 99. The STEP 2 ensures the loop only increments by 2, thereby producing only odd numbers.


What is odd loop in 'C' program?

odd loop means at least the loop execute once.


How do you use even and odd numbers for loop and if condition with variable please no use int?

how to use even and odd number with for loop and if condition plz dont use "int"..


What is odd loop?

Move the print out requesting the user to enter an integer outside of the for loop and it will only print once instead of each time around the loop. You'll need a way to save the even and odd numbers that you detect in the loop. One way is to have separate arrays to hold the even and the odd numbers as you go around the loop. Then at the end of the loop you can have more loops to print the contents of one array and then the contents of the other array. Another way is to concatenate the number onto separate Strings (even and odd) to be displayed after the data gathering loop.


What is the largest odd number with 1465?

Using those 4 digits 6451 is the largest odd number you can make.


What is the largest form of odd number using 4709?

The largest odd number that can be made with those digits is 9407 .


What is the biggest odd number when using 8925?

9825


What is the greatest odd number using 76038?

87603


How do you find a number is odd or even numbers using flowchart?

Get number Find modulo 2 of number If the result is zero, number is even Else number is odd


How can you write a c program using while loop that will print first ten odd numbers?

#include&lt;stdio.h&gt; int main () { int odd=1; int count=0; while (count++&lt;10) { printf (%d\n", odd); odd+=2; } return 0; }


How will you put twentyone marbles in four boxes using odd number without repetition?

it's impossible because the sum of any two odd numbers equals an even number; odd# + odd# = even#. even# +even# = even#. odd# + odd# + odd# + odd# = even#.