+ 2

Please let me know why this error occurs!

int a=2; cout<< a++++; //lvalue required as increment operand.

29th Dec 2020, 9:09 AM
Win Htay 🇲🇲
Win Htay 🇲🇲 - avatar
5 Antworten
+ 4
Is it like, (a++) + (++) ? What does it mean? But if you wrote (a++) + (++a) (output : 6) or, (a++) + (a++) (output : 5) Then it's making more sense right? But wait ✋ This will throw warning because it is unspecified whether (a++) or (++a) will be evaluated first. As I'm not a c++ expert so for further info on Sequence point I'll suggest you to go through this article👇 https://stackoverflow.com/questions/4176328/undefined-behavior-and-sequence-points
29th Dec 2020, 9:34 AM
Minho
Minho - avatar
+ 3
How did you increment like that lol . There's no ++++operator . Either use pre increment or post increment operator . Eg : As in your Qstn let a=2; cout<<a++; is fine //outputs 2 cout<<++a; //outputs 3
29th Dec 2020, 9:24 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 2
hiii i want to take input elements from user and show that elements only using single for loop...
24th Jun 2021, 7:19 AM
Sandesh Walunj
Sandesh Walunj - avatar
+ 1
Alphin K Sajan Many thanks for your answer. But i once saw this in a question! I know temp copy is used in postfix but not in prefix. So postfix is rather tricky! I just want to know trick of step by step bro! I want to be more ckear!
29th Dec 2020, 9:38 AM
Win Htay 🇲🇲
Win Htay 🇲🇲 - avatar
29th Dec 2020, 9:35 AM
Irbaye