473,414 Members | 1,690 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,414 software developers and data experts.

Variable name incrementation

How do you increment a variable name in loop. For example I have a
variable K1 and I want to increment the name by one everytime I go
through the loop to K2, K3, K4 and so on. Thanks.
Jul 22 '05 #1
3 5071

"everett" <ev************@mol-son.com> wrote in message
news:b2************************@posting.google.com ...
How do you increment a variable name in loop. For example I have a
variable K1 and I want to increment the name by one everytime I go
through the loop to K2, K3, K4 and so on. Thanks.


You cannot increment a variable name, in a loop or anywhere else.

Perhaps you need to use an array instead of a variable. Post the code you
are having difficulty with.

john
Jul 22 '05 #2
everett wrote:
How do you increment a variable name in loop. For example I have a
variable K1 and I want to increment the name by one everytime I go
through the loop to K2, K3, K4 and so on. Thanks.


I think the simplest way is useing an array. But if you'll stick to names
generative programming in conjunction with loop unrolling may help you

Andreas
Jul 22 '05 #3
In article <b2************************@posting.google.com>,
everett <ev************@mol-son.com> wrote:
How do you increment a variable name in loop.
You can't.
For example I have a
variable K1 and I want to increment the name by one everytime I go
through the loop to K2, K3, K4 and so on. Thanks.


Why not use an array, or better, a vector?

vector<double> K(10);

for (int pos = 0; pos < 10; ++pos)
{
// do something with K[pos]
}

--
Jon Bell <jt*******@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Scott | last post by:
I have an XML Document in a format like: <Variable name="Bob">ABCDEFG</Variable> <Variable name="Steve">QWERTYUI</Variable> <Variable name="John">POIUYTR</Variable> <Variable...
4
by: Frederik Sørensen | last post by:
I include a xslt stylesheet with variables for all the error messages in my system. <xsl:variable name="Banner_error_1"> errormessage 1 for banner </xsl:variable> <xsl:variable...
166
by: Graham | last post by:
This has to do with class variables and instances variables. Given the following: <code> class _class: var = 0 #rest of the class
16
by: Joona I Palaste | last post by:
Reading Skybuck Flying's obvious troll message, I thought of how to properly do a for loop that would iterate over the complete range of an unsigned variable. As you all know, Skybuck's method...
4
by: N. Demos | last post by:
Hello, I'm learning ASP.NET, and am having a strange problem with some example code from the book I'm using. The code increments and displays the value stored in a session variable when the "Add"...
4
by: sam | last post by:
hI, I am little confused here See i have int wordlen=10; when int s is array s++; whats the meaning of this
1
by: woody79 | last post by:
This is my code: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html...
2
by: sanctus | last post by:
what is the difference between for(j=0;j<cl.ts->size();++j){ double l=cmbcalc->j2l; } and
6
Dormilich
by: Dormilich | last post by:
Hi, I’ve got a mathematical script, which is currently running fine*, although it bothers me that JS does not always increment correctly. sometimes it happens that the incremented value is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.