+ 2

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

20th May 2023, 9:16 AM
đ˜Ÿđ™€đ™™đ™š đ™’đ™žđ™©đ™ 𝘿𝙖𝙧𝙠
6 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
20th May 2023, 9:57 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - 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