Write a program to display only even number and ignoring the odd numbers from a range given by the user. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 5

Write a program to display only even number and ignoring the odd numbers from a range given by the user.

programming in java

19th Feb 2017, 11:20 AM
jatin arora
8 Answers
+ 2
Easy enough, where's the problem? Note: A number n is even if n % 2 == 0
19th Feb 2017, 11:29 AM
Robobrine
Robobrine - avatar
+ 2
please post the code which you had tried already, then we can correct your mistakes. Do not expect the code.
19th Feb 2017, 11:30 AM
Kommoju Sunil Kumar
Kommoju Sunil Kumar - avatar
+ 1
Already Robobrine has given you a hint about how to find even number. Try to code it step by step. 1. Take the user input by using scanner, and print the user input using println 2. Use a for or while loop and Print the numbers in between that range 3. Use an IF statement and print the even numbers only
19th Feb 2017, 11:44 AM
Kommoju Sunil Kumar
Kommoju Sunil Kumar - avatar
+ 1
Do u need to submit any college assignment? Don't expect the entire code here bro.. just think instead of posting "pls sir", " pls pls"
19th Feb 2017, 12:02 PM
tharun surya dwivedula
tharun surya dwivedula - avatar
+ 1
class JavaExample { public static void main(String args[]) { int n = 100; System.out.print("Even Numbers from 1 to "+n+" are: "); for (int i = 1; i <= n; i++) { if (i % 2 == 0) { System.out.print(i + " "); } } } } Output: Even Numbers from 1 to 100 are: 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100
1st Jul 2020, 8:26 AM
💕💞💕Neelam💕💞💕
0
Yeah, as Sunil told, there's no point in keeping the entire code here because u need to develop it.. already he and robobrine have explained the algorithm in detail.. try the code bro..
19th Feb 2017, 11:52 AM
tharun surya dwivedula
tharun surya dwivedula - avatar
0
Pls jatin.. don't waste ur time (which I don't think u r valuing) and ours.. just go into a room, lock urself in and think, think, think.. bye
19th Feb 2017, 12:05 PM
tharun surya dwivedula
tharun surya dwivedula - avatar
0
use continue in for loop example: for(i=0;i<n;i++) { if(a%2==o){ document.write(a) }else continue; }
30th Mar 2017, 5:58 PM
sai Kumar
sai Kumar - avatar