473,320 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Program the displays even numbers only!!

I ned help in figuring out to make my program display even numbers only. My for loop counts every number, but I only need to display the even ones. Can someone help me with this?
Feb 15 '07 #1
4 2954
I figured it out no need to respond to the above message!

Thanks
Feb 15 '07 #2
Ganon11
3,652 Expert 2GB
Glad to see you got it working. Out of curiosity, what method did you implement?
Feb 16 '07 #3
What I did was
int [] numbers = {0,2,3,4,6,8....};
for (int item : numbers)
was suppose to do I misread the instructions.
Feb 16 '07 #4
r035198x
13,262 8TB
What I did was
int [] numbers = {0,2,3,4,6,8....};
for (int item : numbers)
was suppose to do I misread the instructions.

Expand|Select|Wrap|Line Numbers
  1.  int [] numbers = {0,2,3,4,6,8....};
will not compile.

You should have used aloop instead that counts to the largets number you want and tested for even using the % operator.
Feb 17 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Anonieko Ramos | last post by:
You can use the OnKeypress javascript event Evaluate the keypress on the function > > > <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
1
by: Caro | last post by:
Hello, Is it possible to create a sort of validation rule that will limit the data entry in a field to even numbers only ? thaks, Caro
17
by: Ron | last post by:
I want to write a program that will accept a number in a textbox for example 23578 and then in a label will display the sum of the odd and even number like this... the textbox containsthe number...
6
by: devoreband | last post by:
hey i wrote all my code but i need to print out only the even numbers so is there any predefined function i can use or what can structure i should be following? ........ 16 for(int r = 0;...
1
by: psalmprax | last post by:
who can write a C-program on perfect numbers from 1 to 1000?
7
Shinzon
by: Shinzon | last post by:
Hey guys and girls, I am pretty well versed in perl, but am just learning Java and I was wondering if anyone could explain how I would ask for an input of only even numbers or maybe point me in...
2
by: colordrm88 | last post by:
Here is what I am supposed to do...Write a C++ program that asks for 10 numbers and prints the sum of only the even numbers. I also have to use an if statement and a while loop. Please please...
1
by: jonkillua | last post by:
hi guys, i'm creating a program that instead of using the print method to display the odd/even numbers, i want to display the result in label.caption. Im crazy about it, please help me. Private...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.