EQUALITY TEST

There are many times when we need to ask the computer if two variables contain an "equal" value (e.g., x == y), or if one variable contains a value equal to a known constant (e.g., x == 5). Equality is represented in the program using the DOUBLE EQUAL signs operator. The Equality operator (==) should not be confused with the assignment operator.

To test if two variables contain equal values, we use the == notation. Here is an example:

x = input('Person 1, give me a number: '); 
 y = input('Person 2, give me a number: '); 
 
        if ( x == y ) 
          fprintf('You both think alike!\n'); 
        end 
        


         
         
        
Posted on by