+10

I still don't understand how programming work?

I am stress with Swift loop, Python loop and stuff... the ++ and -- sign is so confusing

37 Answers

New Answer

+24

Duplicate IT ++ means "keep adding" while -- means "keep subtracting" Therefore, if i = 1, And we want to keep adding 1, then we'll say, i++ i becomes 2 [i.e. i = 2] i ++ again i will now become 3 [i.e. i = 3] And that's how it goes on... If we want to add 3, It will be: i += 3 (or i = i + 3) So if i = 0; And we say, i += 3, then i will be 0 + 3 which is 3. i += 3 again ...will give you 3 + 3 = 6. i += 3 again ...will give you 6 + 3 = 9. i += 3 again ...will give you 9 + 3 = 12. And it keeps going that way forever...

+8

++ is used to increase/increment the value of a variable by 1. In other words, it adds 1 to the variable. -- subtracts 1 from a variable. Loops are used for repetition.

+5

V F Yes, it is the same in JS and many other OOP languages like Python, etc.

+4

Please note that ++ and -- are not available in Python. Edit: oh I realise you may be using Swift.

+4

V F This is for you. https://code.sololearn.com/Wtg4Xc2nITd6/?ref=app

+4

Operators 1. ++ increment 2. -- decrement There are two types of increment(++) and decrement(--) operator : - (i) pre increment (ii) post increment (i) pre increment increment the values first then assign to variable. Ex: - int i =7; System.out.println(++i); // printing the variable in java O/p - 8 Here, i is incremented first by 1 and then printed so became 8 Pre Decrement System.out.println(--i); // printing the variable in java O/p - 6 Here, i is Decremented first by 1 and then printed so became 6 (ii) Post Increment is assign tge value to variable first then incremented by 1. Ex:- int i=7; System.out.println(i++); // printing statement in java O/p - 7 Here, i is printed first then assigned to variable i if we print i variable again it will print 8. Post decrement assign the value first then decremented by 1 same as post increment Ex :- int i = 8; System.out.println(i--); O/p - 8 Here, variable i printed first then incremented On printing i again System.out.println(i); o/p- 9

+4

Hopefully, by now you understand 😊

+3

++ increases the value by 1 and not by 2.

+3

Duplicate IT 👍

+3

Those are binary operators requiring two operands e.g. a and b. a=1 b=2 print(a+b) # gives 3 print(a-b) # gives -1

+3

i+=3 is the same as saying i=i+3.

+3

BTW, when using i+=3, note that the operator is += and not just +

+3

It will be 3 more than what it was before the statement.

+3

Just read it all slowly again

+3

At start it will seem little bit confusing, but when you start praticing you will start to understand the concept behind it and then you can talk with your computer.

+3

👑Duplicate IT💫⚘🌚 (Storm Me) I can understand your problem. You are unable to understand how programming work, it means there is something wrong with your C basics. You can improve it by first clearing the basics of C and then moving to other programming languages.

+2

Sonic so what is single plus? + or -

+2

Sonic where did u see the +i or i+ Like i+ = 3, i dont remember, but it like that Can you explain?

+2

Sonic so what is the value of i, if i = i+3😂

+2

https://code.sololearn.com/cz2U7fj2BQ14/?ref=app