+ 2
Difference between equal to (==) and assignment operator(=)?
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)
+ 7
đŸđ€đđ đđđ©đ đżđđ§đ Before you ask the question do search on google
https://code.sololearn.com/W0uW3Wks8UBk/?ref=app
+ 2
đŸđ€đđ đđđ©đ đżđđ§đ
'=' sign used for assigning variables :-
Eg. int x=0;
And '==' sign is used for comparisons :-
Eg. if(x==0){cout<<"Hello";}
+ 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"
+ 1
"==" this used for comparison and "="this is used for assigning value to variables and constants