Why is there error in this code ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why is there error in this code ?

#include <iostream> using namespace std; int main() { int a = 2 ; a = a++; cout << a; return 0; }

10th Oct 2020, 6:45 AM
Uttaran Das
Uttaran Das - avatar
1 Answer
+ 1
There is not error in this code. Although it will generate a warning regarding "a = a++" statement which may lead to undefined behaviour, but program will still run and generate output.
10th Oct 2020, 6:54 AM
Arsenic
Arsenic - avatar