C Programming Tutorial – 24 – Increment Operator

Facebook – https://www.facebook.com/TheNewBoston-464114846956315/
GitHub – https://github.com/buckyroberts
Google+ – https://plus.google.com/+BuckyRoberts
LinkedIn – https://www.linkedin.com/in/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/
Twitter – https://twitter.com/bucky_roberts

Comments

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;
answer = ++a * b;
// (1+5) * 10 = 60

a = 5, b = 10, answer = 0;
// for a++ Bucky explain: Computer do 5 * 10 first, than ++
answer = a++ * b;
// 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
Hope I help you guys out

Your Average Talking Potato says:

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!

Pradeep Dewangan says:

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?

saada diddi says:

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:

Is it necessary to put answer=0 .I mean how about only int answer; ??

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();

}

Bahaddin A. Hussein says:

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

james brown says:

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

Hamzah Ahmad says:

Is it necessary to assign the value ‘0’ to the variable ‘answer’ in the first line? I tried the code without assigning 0 to answer and it worked fine

Write a comment

*

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles▷ Show Cars▷ Motorbikes▷ Scooters▷ Bicycles▷ Rims & Tires▷ Luxury BoatsFashion▷ Sunglasses▷ Luxury Watches▷ Luxury Purses▷ Jeans Wear▷ High Heels▷ Kinis Swimwear▷ Perfumes▷ Jewellery▷ Cosmetics▷ Shaving Helpers▷ Fashion HatsFooding▷ Chef Club▷ Fooding Helpers▷ Coktails & LiquorsSports▷ Sport Shoes▷ Fitness & Detox▷ Golf Gear▷ Racquets▷ Hiking & Trek Gear▷ Diving Equipment▷ Ski Gear▷ Snowboards▷ Surf Boards▷ Rollers & SkatesEntertainment▷ DIY Guides▷ Zik Instruments▷ Published Books▷ Music Albums▷ Cine Movies▷ Trading Helpers▷ Make Money▷ Fishing Equipment▷ Paintball Supplies▷ Trading Card Games▷ Telescopes▷ Knives▷ VapesHigh Tech▷ Flat Screens▷ Tech Devices▷ Camera Lenses▷ Audio HiFi▷ Printers▷ USB Devices▷ PC Hardware▷ Network Gear▷ Cloud Servers▷ Software Helpers▷ Programmer Helpers▷ Mobile Apps▷ Hearing AidsHome▷ Home Furniture▷ Home Appliances▷ Tools Workshop▷ Beddings▷ Floor Layings▷ Barbecues▷ Aquarium Gear▷ Safe Boxes▷ Office Supplies▷ Security Locks▷ Cleaning ProductsKids▷ Baby Strollers▷ Child Car Seats▷ Remote ControlledTravel▷ Luggages & Bags▷ Airlines Seats▷ Hotel Rooms▷ Fun Trips▷ Cruise Ships▷ Mexico Tours