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

making more than one test in a 'for' statement ?

Hi....
I would just like to know about whether I can make more than one test
in one for statement...
As I would like to know this in relation to a project I am working on
(simple-the-game.sf.net I think)
there is no webpage but that is my project page.
There is no code either but that is mainly becourse I haven't got
anything up by now.... It is a game, or it is something that should
turn out as a console game (text based).

Greetings from Denmark.

Oct 3 '07 #1
3 1167
ThaDoctor wrote:
I would just like to know about whether I can make more than one test
in one for statement...
The second part of a 'for' statement is a logical expression, you can
put any expression you wish in there. Use &&, ||, ==, !=, to combine
logical subexpressions.
As I would like to know this in relation to a project [...]
That's irrelevant.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Oct 3 '07 #2
On 2007-10-03 16:56, ThaDoctor wrote:
Hi....
I would just like to know about whether I can make more than one test
in one for statement...
As I would like to know this in relation to a project I am working on
(simple-the-game.sf.net I think)
there is no webpage but that is my project page.
There is no code either but that is mainly becourse I haven't got
anything up by now.... It is a game, or it is something that should
turn out as a console game (text based).
Use the logical operators && or || to separate the test, so if you want
to check if both a and b are greater than 0 then you write

if (a 0 && b 0)

If you only need one of them to be greater then 0 use || instead.

--
Erik Wikström
Oct 3 '07 #3
"ThaDoctor" <To*********@gmail.comwrote in message
news:11*********************@y42g2000hsy.googlegro ups.com...
Hi....
I would just like to know about whether I can make more than one test
in one for statement...
As I would like to know this in relation to a project I am working on
(simple-the-game.sf.net I think)
there is no webpage but that is my project page.
There is no code either but that is mainly becourse I haven't got
anything up by now.... It is a game, or it is something that should
turn out as a console game (text based).
Like Victor and Erik said, you need to use boolean and and or.

int count = 0;
for ( int i = 0; i < 100 && count < 5; ++i )

Which would continue until either i is greater than 100 or count is greater
than 5.
Oct 3 '07 #4

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

Similar topics

5
by: Willam Roberts | last post by:
To me, when you enumerate, you make a list of specific items, like enumerating controls in a form. Am I missing something? I mean is there something more to the meaning of the term "enumeration" or...
2
by: Stewart | last post by:
Originally posted in comp.lang.javascript: Newsgroups: comp.lang.javascript From: "Stewart" Date: 23 Aug 2005 02:50:04 -0700 Local: Tues, Aug 23 2005 10:50 am Subject: FireFox, RemoveChild,...
19
by: Christian Fowler | last post by:
I have a VERY LARGE pile of geographic data that I am importing into a database (db of choice is postgres, though may hop to oracle if necessary). The data is strictly hierarchical - each node has...
5
by: serge | last post by:
Is it generally or almost always better to have multiple small SPs and functions to return a result set instead of using a single big 1000+ lines SP? I have one SP for example that is 1000+...
37
by: yogpjosh | last post by:
Hello All, I was asked a question in an interview.. Its related to dynamically allocated and deallocated memory. eg. //start char * p = new char; ...
3
by: Yong | last post by:
I get a general network error when I try to make asynchronously call ExecuteNonQuery on long sql statements that run in parallel. Here is the background info on what I'm trying to accomplish: I...
351
by: CBFalconer | last post by:
We often find hidden, and totally unnecessary, assumptions being made in code. The following leans heavily on one particular example, which happens to be in C. However similar things can (and...
4
by: abendstund | last post by:
Hi, I have the following code and trouble with ambiguity due to operator overloading.. The code is also at http://paste.nn-d.de/441 snip>>
11
by: Rafe | last post by:
Hi, I'm working within an application (making a lot of wrappers), but the application is not case sensitive. For example, Typing obj.name, obj.Name, or even object.naMe is all fine (as far as...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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,...

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.