0

Why if I write this code :

#include <iostream> using namespace std; int main() { int a; cin>>a; if (a='Hi'){ cout<<"Hi"; } else { cout<<"Norm"; } return 0; }

25th Dec 2018, 5:16 PM
INTRO Tech inc.
INTRO Tech inc. - avatar
3 ответов
+ 2
Use == instead of = in the if condition. = is used for assignment of variables while == to compare values.
25th Dec 2018, 5:29 PM
TurtleShell
TurtleShell - avatar
+ 1
If parameter should contains Boolean expression As told by TurtleShell , you have to use == instead of = a=="Hi" is a Boolean expression a="Hi" is not
25th Dec 2018, 5:37 PM
Rishi Anand
Rishi Anand - avatar
0
Why error?
25th Dec 2018, 5:17 PM
INTRO Tech inc.
INTRO Tech inc. - avatar