+ 2

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

20th May 2023, 9:16 AM
𝘾𝙤𝙙𝙚 𝙒𝙞𝙩𝙝 𝘿𝙖𝙧𝙠
4 ответов
+ 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
20th May 2023, 9:57 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - 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