## C Programming Tutorial – 24 – Increment Operator

GitHub – https://github.com/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/

Tannya Seth says:

seriously , you are the best teacher. i never listen so carefully 😛

thanks a lot

sir!

Patrick Sedjro says:

How can answer be assigned a value of 0 and then changed later? I thought that once you initialize a variable, that value is constant throughout that whole code?

Jean-Sébastien Lemaire says:

That’s useful. Last time I wanted to add 1 to a variable I did this: variable = variable + 1;. This is a lot quicker and more useful.

Vicente Chimenes says:

a++ or ++a isnt changing nothing for me in my C.

lord bumus says:

Bucky: I REEEEEEEEEEAAAAAAAAAAAAAAAAAAAALLLLLLLLLLLLLLLLLYYYYYYYYYY like tuna

Aido97 says:

awesome  tutorial keep it up!

yerrapotu kiran says:

Thank you bucky

Sagar Khanapurkar says:

BODMAS !!

Vincent Mo says:

So for those you don’t understand this let me explain in a better way. Read the comment line.
int a = 5, b = 10, answer = 0;
// (1+5) * 10 = 60

a = 5, b = 10, answer = 0;
// for a++ Bucky explain: Computer do 5 * 10 first, than ++
// If you add “+ a” at the end, Ex:  a++ * b + a; the answer will be 56, once you type “+ a” and run it you will able to understand why a++ * b = 50

Because ++ is after “a” so 5 * 10 = 50. In this step ++ is not doing because it already end with the ; (Semicolon)
if you want “++” to do something add “+ a” at the end. than ++ will change a = 5 to a = 6

DUDE I’ve spent like 4 hours of my time on YouTube and not a single thing had I gained until I came by to your tutorial… You’re amazing!

Hey,Bucky great job man. I am learning c language quite fast. Thanx

Betsy B says:

I got it got it.

Rohit Patil says:

Hey Bucky ur Awesome…..
Plz keep up d good work
Great tutorials…..!!

Hyunjoo Lee says:

Anybody can explain why  a++ * 10 is still 50 on the screen?
because i think,
the calculation is already done right after the code “answer = a++ * 10 ;”
and the printf came after the calculation is done , which is supposed to print out “60”.
I still don’t understand,

Ameen Sayegh says:

hey bucky
why you don’t make advance tutorials series
instead of repeating the same series again and again

Sean Brown says:

You know Bucky, you’re amazing.

Christopher Pilcher says:

If anyone is still confused, type this into your code:

int a = 5;
printf(“%dn”, a++);
a = 5
printf(“%dn”, ++a);

ankit agrawal says:

it gives warning : comparison of string literal leads to unspecified behaviour

Flamer Joe says:

This video is the living proof that Clicker Heroes is the easiest game to code

lilo Rouif says:

hey dude you’re reeeally a life saver THANNKS !!!!

A t says:

When you went to Cracker barrel how was the service? Have you gone recently since they fired Brad’s wife? Has the service changed?

Shaikh Shamim says:

sir
instead of 1 incement how to incrrment 0.10?

it’s just today i found this videos and i hv more than 50 of them to download. i can’t start watching now cuz i hav to finish the download first but i really hope it will help me out

Greg Bush says:

I was gonna say isn’t it because of order of operations why the second line equals 50? Because the ++ was on the right side of “a” meaning that it will be multiplied first before the 5?

Pavel says:

i dont understand why do i have to copy the a and b values into the 2nd part i mean i havent changed them in any way

Poojan Patel says:

you are awesome i like your videos….thank you so  much you videos are also so much help full…..

Bra him says:

Oh.. I think bucky didn’t explain the ++ thing perfectly…

It’s mathematically simple :
Why a++ * b = 50 ?

a++ * b  :::: means :::: a + 1 * b = 5 + 1 * 10 = 5 * 10 = 50
Multiplication first.

IndiCoder says:

Jesper says:

thought it was my phone

Thai Bui says:

What is your result and why it is?

void main(void)

{
int a,b;
a=3;
b=a++ + ++a;
printf(“%d,%d,%d,%d”,b,a++,a,++a);
getch();

}

Wonderful work, the simplest way to learn C… Thank you Bucky

james brown says:

i’m here now!!! yay!! lesson 24!!