answersLogoWhite

0

final int limit = 1000000;

// Print evens...

for(int i = 0; i <= limit; i += 2) {

System.out.print(i + " ");

}

// Print odds...

for(int i = 1; i <= limit; i += 2) {

System.out.print(i + " ");

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

How do you print numbers as even numbers in a loop in qbasic?

To print even numbers in a loop in QBasic, you can use a FOR loop to iterate through a range of numbers and check if each number is even. An even number can be identified using the modulus operator (MOD). Here's a simple example: FOR i = 1 TO 20 IF i MOD 2 = 0 THEN PRINT i END IF NEXT i This code will print all even numbers from 1 to 20.


Q2 Write a program to print even numbers between 10 and 50?

You can use int i; for (i = 10; i &lt;= 50; i += 2) {//print i} as a program to print even numbers between 10 and 50.


What Program that will display the even numbers in data structures and algorithms?

JAVA


Print sum of first ten even numbers?

It is 110.


Write an algorithm to print sum of all even numbers?

Start print "the sum of all even numbers is infinite" end


How do you write a program in java to read ten numbers and print sum of ten integers?

Add the numbers into one variable as you read them in. But if you prefer, you can read the numbers into an array and then use a loop to add the numbers together.


How do you print even number in qbasic?

In QBasic, you can print even numbers using a simple loop. For example, you can use a FOR loop to iterate through a range of numbers and then check if each number is even by using the modulus operator (MOD). Here's a sample code snippet: FOR i = 1 TO 20 IF i MOD 2 = 0 THEN PRINT i NEXT i This code will print all even numbers from 1 to 20.


Write in BlueJ to print lucky numbers?

To print lucky numbers in java, you must give the following program: class example { static public void main(String[] args) { System.out.println("Lucky number is your favourite number which is your DOB"); } }


Write a java script program to print first ten odd natural numbers in C?

Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.


What is java program on computers?

#!/usr/bin/perl print 'java program';


How can you print a table of 5 in java by getting values from user?

look at the print


Java code to print prime numbers from 1 to 10?

System.out.println("2, 3, 5, 7"); There are so few you dont need to calculate it