In c++, int a=5,b=2,c; cout<<c=(a%b); show error why someone help me.?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

In c++, int a=5,b=2,c; cout<<c=(a%b); show error why someone help me.??

21st Jan 2022, 2:50 PM
Vinit Kumar.
Vinit Kumar. - avatar
2 Answers
+ 3
/Playground/file0.cpp: In function 'int main(0: /Playground/file0.cpp:6:13: error: no match for 'operator= (operand types are 'std::basic_ostream<char>' and 'int) 6 cout<<c=(a%b); This happens because C++ can't find a matching operator = overload in template class std::basic_ostream The = operator in the expression `c = ( a % b )` is the culprit. If you want, you can wrap the whole expression inside parentheses like std::cout << ( c = ( a % b ) ). This way the whole expression `( c = ( a % b ) )` will be evaluated first, and only the evaluation result (1) will be inserted into the output stream, std::cout
21st Jan 2022, 3:08 PM
Ipang
+ 1
Thank you.
21st Jan 2022, 3:15 PM
Vinit Kumar.
Vinit Kumar. - avatar