C++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

C++

#include <iostream> using namespace std ; int main() { int x=12; int y=7; ----x; cout<<--x<<endl; ++++++y; cout<<++++y<<endl; cout<<----x<<endl; y++; cout<<y<<endl; ----x; cout<<x<<endl; cout<<------y; } Is there any one has another way to solution it

17th Mar 2021, 3:29 PM
hashem hubaish
hashem hubaish - avatar
3 Answers
+ 2
What are you trying to solve anyway 🤣
17th Mar 2021, 8:03 PM
ogoxu
ogoxu - avatar
+ 1
How to make the variable is growing step or more or decrease without ---- double or ++++
18th Mar 2021, 2:46 PM
hashem hubaish
hashem hubaish - avatar
+ 1
See, You can use the increment (++) or decrement (--) only once at a time. you can use ++a; ++a; two times but you can't use ++++a; for the same result. If you want to increment a variable many times you can use loops like for(int i=0;i<10;i++) { ++a;} But adding the +/- sign many times won't work. Keep it clear.
19th Mar 2021, 1:43 PM
Illa Bahadur Darlami Magar
Illa Bahadur Darlami Magar - avatar