English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Can someone please put it as simply as possible? Thanks!

2006-10-31 21:32:26 · 1 answers · asked by Anonymous in Computers & Internet Programming & Design

1 answers

= is used to assign a value to a variable.
== is used to compare if two arguments are equal. For example.

a = 5;
This assigns the value of 5 to the variable 'a'

a == 5
This returns the value of true if a is equal to five, or false if a is not equal to 5. This one is typically used in if statements and while statements to decide which branch of code to follow, for example:

if (a==5) {
// Do something when a is equal to 5, like make a equal to 7.
a = 7;
} else {
// Do something when a isn't equal to five - like assign the value of 0 to the variable a
a = 0;
}

2006-10-31 21:42:31 · answer #1 · answered by Isofarro 3 · 1 0

fedest.com, questions and answers