473,398 Members | 2,368 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,398 software developers and data experts.

algorithm to find first n even numbers

algorithm to find first n even numbers
Apr 20 '18 #1
1 1644
weaknessforcats
9,208 Expert Mod 8TB
You use nested loops.

The outer loop runs for 7 cycles..

The inner loop begins with an int set to 2 and tests it to be even. If even, the loop displays the int and exits. if not even the loop inrements the int and repeats the test for even again.

By the time the outer loop exits, the inner loop wsill have displayed 7 values.
Apr 21 '18 #2

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

Similar topics

1
by: D.M | last post by:
Hye, I have a form with 8 telephone number fields. I want to take only first two numbers and make a new field called network group. Please can you help me? Thanks
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...
4
by: ghostrider | last post by:
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?
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;...
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...
4
code green
by: code green | last post by:
Data Protection etc.... shouldn't be there. How do I find credit card numbers buried amongst any length of text. Googling finds credit card validation claims, which are too complicated. I need...
2
by: Gunabalan123 | last post by:
To select even or odd IDs from a MySQL table, you would use the 'MOD', this easy way to select the Odd and Even numbers/. Odd number select... select column_name from table_name where...
1
by: 5161570 | last post by:
How will I write an algorithm to display odd numbers from 20 to 1. And further add the odd numbers.
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.