odd numbers with loop

odd numbers with loop

get the odd numbers till 100 with for,while loop

View Answers

March 3, 2011 at 11:04 AM

Java find odd numbers:

class OddNumbers 
{
    public static void main(String[] args) 
    {
        for(int i=1;i<=100;i++){
            if(i%2!=0){
                System.out.println(i);
            }
        }
    }
}

class OddNumbers 
{
    public static void main(String[] args) 
    {
        int i=1;
        while(i<=100){
            if(i%2!=0){
                System.out.println(i);
            }
            i++;
        }
    }
}









Related Tutorials/Questions & Answers:
odd numbers with loop
odd numbers with loop  get the odd numbers till 100 with for,while loop   Java find odd numbers: class OddNumbers { public static void main(String[] args) { for(int i=1;i<=100;i
Calculate sum of even and odd numbers in Java
Calculate sum of even and odd numbers In this section, you will learn how to read the file that contains even and odd numbers and calculate their sum separately. To do this, first of all, we have found all the even and odd numbers from 1
Advertisements
To find first two maximum numbers in an array,using single loop without sorting array.
To find first two maximum numbers in an array,using single loop without sorting array.  Java program to find first two maximum numbers in an array,using single loop without sorting array
To find first two maximum numbers in an array,using single loop without sorting array.
To find first two maximum numbers in an array,using single loop without sorting array.  Java program to find first two maximum numbers in an array,using single loop without sorting array
A program to find the sum of odd number
to the number provided by user. Within the loop checking for odd number...A program to find the sum of odd number In this section you will learn how to find the sum of odd number in the series up to the given number in java
Check whether highest number is even or odd
Check whether highest number is even or odd In this section, you will learn how to check highest number between the two numbers and then determine whether it is odd or even. For this, we have taken two integer variables num1 and num2
odd and even
odd and even  how can i make a program of even and odd using case...); System.out.println("Enter Numbers: "); int arr[]=new int[10..."); System.out.println("2 Display Odd"); System.out.println("3 Exit
Check even or odd number.
by 2, and odd numbers are not divisible by 2. if((num %2)==0) is checking...Check even or odd number.  How to check given number is even or odd?   Simple if it is devided by 2 it is even and if not if is Odd  
Even and odd functions in java
and which is not divisible by 2 is called odd numbers. Here we...Even and odd functions in java  Even and odd functions in java  ... or odd:"); number = input.nextInt(); evenMethod( number
while loop to for loops
: "+currentNum); } else{ System.out.print("Odd numbers... numbers and sum of even numbers System.out.print("Odd Numbers...++; } System.out.println( ); System.out.println("Sum of square of odd numbers
loop
loop  what is the difference b/w do while,while and for loop..with example
loop
loop  i want to write my name(inder) through loop in java using star
for loop
for loop  using only two for loop how can print below numbers 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 8 8 8 8 8 8 8 8 7 7 7 7 7 7 7 6 6 6 6 6 6 5 5 5 5
for loop
for loop  using only two for loop how can print below numbers 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 8 8 8 8 8 8 8 8 7 7 7 7 7 7 7 6 6 6 6 6 6 5 5 5 5
for loop
for loop  what is for loop   Loops are used for iteration... for a number of times it is finite loop and if repetition is done infinitely it is infinite loop. Java provides several loop structures for iteration. Those
for loop
for loop  hai, I need to write java program to print numbers in "X" format
For loop
For loop  Hi! Please explain the following loop: for(i=0;i<a[j];i++) THANX!!   Please reply as soon as possible
ModuleNotFoundError: No module named 'odd'
ModuleNotFoundError: No module named 'odd'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odd' How to remove the ModuleNotFoundError: No module named 'odd' error
for loop
for loop  how to performs the for loop when 2 inputs given like displays the triangle shape and how to take initial values or declaration values plz explain in detailed ex. 1 12 123 1234
Loop
to understand a loop my quesiton are: what du i do wrong in my code since.... (made in blueJ) Class Loop public void loopUpGeneral(int start, int stop... dk  Hi, Please check the for loop once again: for (int i
For Loop
For Loop  Write a program using a for loop that computes the following sum: 1/2 + 2/2 + 3/2 + 4/2 + 5/2 + ... N/2 N will be an integer limit the user enters. This is an example of my upcoming quiz. I need help on knowing
loop
loop  strong textHello can someone help me with this problem,I need to output the following code using a loop the code is as follows with the user inputs in inverted commas,thanks. ENTER CODE(XX to Stop) CODE:"D24" QUANTITY:"2
JSTL - check odd/even number - JSP-Servlet
JSTL - check odd/even number  How do i create a JSTL program to generate random numbers and to check whether they are odd/even and print "this is an even (odd) number and it is in between so and so number? e.g. the random number
PRIME AND EVEN AND ODD - Java Interview Questions
? how to write even numbers? i want source code? how to write odd numbers ?i... + " "; } } } System.out.println(primeNo); } } 2) Following code displays Even and Odd numbers... between 1 to 20 are: "+evenNo); System.out.println("Odd Numbers between 1
ModuleNotFoundError: No module named 'odd-bunch'
ModuleNotFoundError: No module named 'odd-bunch'  Hi, My Python... 'odd-bunch' How to remove the ModuleNotFoundError: No module named 'odd... have to install padas library. You can install odd-bunch python with following
loop statements
loop statements  write a program that reads from input an interger n and prints the factorial of all numbers between 1 and n
Java number calculation using while loop
must be less than secondNum.) and output all the odd numbers between firstNum... the odd numbers between firstNum and secondNum inclusive. Example: import...{ System.out.println("Odd Numbers: "); while(num1 <= num2) { if(num1%2 != 0
Prime Numbers
with the first n prime numbers. Your program should then display the contents... a positive value for n, and should loop until they do so
Odd Even Transposition Sort In Java
Odd Even Transposition Sort In Java   ... In this example we are going to sort integer values of an array using odd even transposition sort. Odd even transposition sort is a parallel sorting algorithm. Odd Even
For..in loop
For..in loop         In this tutorial we will study for..in loop which is similar to for each loop of C#, Java and other popular languages, in this example
automorphic numbers
automorphic numbers  how to find automorphic number in java   Hi Friend, Pleas visit the following link:ADS_TO_REPLACE_1 Automorphic numbers Thanks
Java for loop
Java for loop  Can a for statement loop indefinitely
sorting numbers
sorting numbers  How to sort the numbers in ascending order   import java.util.*; class SortNumbers{ public static void main(String...=input.nextInt(); list.add(num); } System.out.println("Numbers
numbers
To find first two maximum numbers in an array
To find first two maximum numbers in an array  Java program to find first two maximum numbers in an array,using single loop without sorting array
Numbers pyramid
Numbers pyramid  Hi sir, Can you please tell me how to output this using nested for loops? 1 2, 1 1, 2, 3 4, 3, 2, 1 1, 2, 3, 4, 5 6, 5, 4, 3, 2, 1 1, 2, 3, 4, 5, 6, 7 8, 7, 6, 5, 4, 3, 2, 1 1, 2, 3, 4, 5, 6, 7, 8, 9 10, 9, 8
Rational Numbers
Rational Numbers   Write and fully test a class that represents rational numbers. A rational number can be represented as the ratio of two integer values, a and b, where b is not zero. The class has attributes for the numerator
For Loop - Struts
For Loop  Hi, How to use for loop in Struts2. I don't want use.... How to use the For loop in JSP. Thanks, Rajesh.  Hi Rajesh, i am sending simple use of for loop. In this example, you will see the use
for( ) loop in php
for( ) loop in php  Generally, when we use for loop in PHP or any other programming language why we use i++ and not ++i. What is the reason behind
for( ) loop in php
for( ) loop in php  Generally, when we use for loop in PHP or any other programming language why we use i++ and not ++i. What is the reason behind
Limits of "For loop"
Limits of "For loop"  Hi, How can I check the upper limit and lower limit of 'FOR' loop during unit testing using Junit. Thanks & Regards Ankit
How to write a loop and a while loop
How to write a loop and a while loop  How do I write a 1 loop and a 1 while loop for the example code: public boolean isTheFirstOneBigger (int num1, int num2) { if (num1 > num2) { return true
Listing all even numbers between two numbers
Listing all even numbers between two numbers  Hi, How to write code to list all the even numbers between two given numbers? Thanks   Hi, You function will take 2 numbers and the find the even numbers between
how to add to numbers in java
how to add to numbers in java  how to add to numbers in java
for loop in java
for loop in java  54321 4321 321 21 1 using for loop or nested 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 using for loop or nested... 8 9 6 7 8 9 10 all for loop code plz friends guide me
for loop in java
for loop in java  54321 4321 321 21 1 using for loop or nested 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 using for loop or nested... 8 9 6 7 8 9 10 all for loop code plz friends guide me
for loop in java
for loop in java  54321 4321 321 21 1 using for loop or nested 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 using for loop or nested... 8 9 6 7 8 9 10 all for loop code plz friends guide me
for loop in java
for loop in java  54321 4321 321 21 1 using for loop or nested 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 using for loop or nested... 8 9 6 7 8 9 10 all for loop code plz friends guide me
loop example
loop example   1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 can you give me the code to get the number pyramid
For Loop/PHP
For Loop/PHP  Write a class called math. It is to have one property... 12345. How would you write this as a loop? Would I need to use the for loop or do/while loop?   PHP Factorial Example: <?php $n = 5; $i = 1; $f

Ads