Difference between equal to (==) and assignment operator(=)? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 2

Difference between equal to (==) and assignment operator(=)?

20th May 2023, 9:16 AM
š˜¾š™¤š™™š™š š™’š™žš™©š™ š˜æš™–š™§š™ 
5 Respostas
+ 9
Assignment operator: used for asigning a value to a variable. int num = 4; ^ Equal to operator: used for comparing two variables: cout << 1==0; // prints 0 (false) cout << 1 == 1; // prints 1 (true)
20th May 2023, 9:28 AM
Ugulberto SƔnchez
Ugulberto SƔnchez - avatar
+ 2
š˜¾š™¤š™™š™š š™’š™žš™©š™ š˜æš™–š™§š™  '=' sign used for assigning variables :- Eg. int x=0; And '==' sign is used for comparisons :- Eg. if(x==0){cout<<"Hello";}
21st May 2023, 4:07 PM
Alhaaz
Alhaaz - avatar
+ 2
The equal operator, means that whatever is coming after that, is getting assigned to that variable. The equal to operator, compares one value with the other. Here is an example: int number = 1; Here is an example of the comparison operator: if(number1 == number2){ cout <<"Hello"
22nd May 2023, 2:42 PM
Danish Zubair
Danish Zubair - avatar
+ 1
"==" this used for comparison and "="this is used for assigning value to variables and constants
21st May 2023, 2:55 PM
G Ramya