+ 1

Is this Wrong - if ( int = 2 ) { cout <<"bla bla bla bla \n"; }

23rd Dec 2017, 11:17 AM
Aditya Gupta
Aditya Gupta - avatar
4 Antworten
+ 2
Yes, it's wrong. int,float,etc. , i.e. datatypes and keywords, can't be used as the name of an identifier. Also, you have used assignment operator where you should have used == operator. So your condition will always return true. use if(number==2) or something similar instead.
23rd Dec 2017, 11:22 AM
DAB
DAB - avatar
+ 2
yes, it is wrong. because in if condition, you should use conditional operator == not assignment operator =.okay
25th Dec 2017, 9:54 AM
KOGANTI POOJA SRAVANI
KOGANTI POOJA SRAVANI - avatar
+ 1
thanks
23rd Dec 2017, 11:22 AM
Aditya Gupta
Aditya Gupta - avatar
0
it's wrong because with if conditions we use "==" Not "=" and we dont use type of variable like you Do the correct syntaxe is if(variable_Name == 2){cout <<"blablabla"<<endl;
24th Dec 2017, 1:55 AM
SAMOUD Tarek
SAMOUD Tarek - avatar