question on ==
ok i want to know exactly what this is....yes im a newbie as its easy to tell
heres an example
else if(age==100)
whats the "==" in the above thing for
is there a particluar reason why there is two equal signs to say that its equal?
- Grimey
It tests for equality.
When you use one = sign, it is an assignment statement.
val = 5; // the number 5 is put in val
(val == 10); // see if val contains the value 10
Martee
Magnum Games.NET
All your code are belong to us.
When you use one = sign, it is an assignment statement.
val = 5; // the number 5 is put in val
(val == 10); // see if val contains the value 10
Martee
Magnum Games.NET
All your code are belong to us.
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
March 15, 2001 09:40 PM
okay look at the following code:
---
int age = 0;
if (age == 0)
do something here
if (age = 10)
do something else
---
the difference is that the "==" is a test for equality, whilst the "=" is a assign operator. So age == 0 returns true or false. Whilst age = 0 says let age be 0.
---
int age = 0;
if (age == 0)
do something here
if (age = 10)
do something else
---
the difference is that the "==" is a test for equality, whilst the "=" is a assign operator. So age == 0 returns true or false. Whilst age = 0 says let age be 0.
The "==" operator is an equality operator. This is NOT the same as the "=" operator which is the assignment operator.
As an example:
age = 100;
This assigns the value of 100 to the variable age.
(age == 100)
This compares the value that is in age to 100. If it is the same then the expression is evaluated to true.
So you could say:
bool isEquals = ( age == 100 )
This assigns isEquals to either true if age is equal to 100 or false if not.
-------
Andrew
As an example:
age = 100;
This assigns the value of 100 to the variable age.
(age == 100)
This compares the value that is in age to 100. If it is the same then the expression is evaluated to true.
So you could say:
bool isEquals = ( age == 100 )
This assigns isEquals to either true if age is equal to 100 or false if not.
-------
Andrew
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement