This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
2

firefish

# What's the difference?.css-1q3m8ps{margin-left:var(--space-4);margin-right:var(--space-4);display:none;}

You've probably used them to increment variable n, but that's not just what they're used for.

# n++

Let's say n = 3;. Let's now do this: Console.WriteLine(n++);. Yes, that's right, n++ and ++n are expressions! n++ will return n, then increment n. So Console.WriteLine(n++); will print 3!

# ++n

n = 3; again. ++n will increment n, then return n.
So Console.WriteLine(++n); will print 4!

# +=

+= is like ++n;. So if n = 3; again, Console.WriteLine(n+=10); will increment n by ten, then print n! So this will print 13!

# This is in C#, C++ and C

So

@HahaYes
will find this works as well.

2 years ago

### Voters

TopNew
1
MultiLangCoder

And Java, JavaScript, Python ALMOST EVERY LANG.

1 year ago
1
firefish

Also forogt to mention

@HahaYes
@DynamicSquid
@CodeLongAndPros
will all find this will work

2 years ago