C Programming Tutorial - 24 - Increment Operator

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

why am i paying for college when i can just watch your channel

LewdtenantLascivious
Автор

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!

youraveragetalkingpotato
Автор

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

pradeepdewangan
Автор

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

bahaddinadil
Автор

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

int a = 5;
printf("%d\n", a++);
a = 5
printf("%d\n", ++a);

buxt-tech
Автор

FYI, '++a' is called the pre-increment operator, as it first increments a and then evaluates the expression. 'a++' is called the post-increment operator, because it forst evaluates the expression and then increments a.

zhupdhk
Автор

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

jamesbrown-yrcz
Автор

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.

jean-sebastienlemaire
Автор

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

alirouifed
Автор

Hey Bucky ur
Plz keep up d good work
Great

RohitPatil_Tech
Автор

That sht cracked me up when he got a call n roasted tf out of whoever it was @ 2:03

ThinkAbstract
Автор

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

IndiCoder
Автор

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

poojanpatel
Автор

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

keylomoon
Автор

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?

gregbush
Автор

int main()
{

int a=2, b = 10, c = 0;
c= a++ * b;
printf(" %d\n", c);
printf(" %d ", a);
return 0;
}
IF we runned that code it will give us:
20
3
that evaluates that what happened first it did A*b then it added 1 to a after the process.
we can say that a++ mean add1 to a after using it

marwanalaa
Автор

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

kumarsanu
Автор

isnt it supposed to be 51 instead of 50 there?

daniel
Автор

sir
instead of 1 incement how to incrrment 0.10?

shaikhshamim
Автор

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,

hyunjoolee