Transcript for:
Understanding Binary and Assignment Operators

Hi, my name is Abdurrahman. I'm a lecturer at a public university in Kenya. I deliver lectures in computing and informatics. In our last lesson, we discussed about bitwise operators and under bitwise operators, we discussed Six bitwise operators we discuss the bitwise AND, the bitwise OR, the exclusive OR, the shift left, the shift right and the complement.

Today we are coming up to the last of our question. What are the binary operators? And we are going to start up with the assignment operators.

An assignment operators basically Also, there are six of them. Let's start with the first one. Let's start with the first one and see what happens So the first one and the assignment operators We have what you call an assignment itself so the assignment itself the symbol is the equal sign and this will assign a particular value to particular variable so this is the assignment sign the equal sign number two we have the add and the assign the add and assign the symbol is written as add and assign so we'll have the add and assign The third one we have the subtract and the assign.

It will be written as these two symbols and this will be the subtract plus assign. The fourth one we have it is the multiply and the assign. So the symbol for multiplication it is an asterisk and equal sign so this will be the multiple plus the assign and the fifth one it is the divide and assign so we have a backslash and this will be the divide plus the assign the sixth one which is the last one will have the modulus and the assign so here we'll have up the modulus and the assign so basically how do you use this particular one let's take for example if I have a equals to 10 and B equals to 20 Now I can assign in a shortcut manner.

So when I say a plus add and assign b this one actually means what? This one actually means a equals to a plus b. So basically what will happen it is we are going to assign a to what a which is 10 plus b which is 20. So the value of a now becomes 30 and here basically the value of a was what was 10. So this is how the assignment operators work.

So let's go to dev C++ to see how we can actually implement it. So here already I have declared two variables of data type integer sign and short. I've given a value of 10 to a and a value of 20 to b.

And then I declared some variables for each and every assignment operator. We had start up with the first one. We are saying here we are assigning a to assign to b. So basically what will happen It is very simple as that.

We are assigning a to b. So a it would be 10 anymore here A will give up the result of 20. Now, let's go to the second one the second part of it. We are saying a Plus equals b.

So the meaning of it a should be should be equivalent to what should be equivalent to a equals to a plus b and a plus b should be equal to what because our a has been assigned 20 plus b which is 20 so our answer you should get up 40. and the second one here basically we are saying what are we saying we are saying A we are saying what about what we're saying here we are saying a assignment B a assignment B minus assignment B should be equal to what should be equivalent should be equivalent to what basically Equal to A equals to A minus B. But already we know that our A here, it is what? 40. So here will be 40 minus B, which is 20. So our answer basically will be 20. We come up to the multiplication part of it.

So the multiplication part of it, we are saying. When we say A multiply assign B, what does it mean? A multiply assign B, it means very simple. It means A equals to A multiplied by B. So let's see what will happen.

So our A, actually now it is 20. multiply by b which is 20 should give us an answer of 400. Let's go to the division part of it. So when we are saying a, a divided by uh equals to b, what do you mean here? Here we basically mean this.

We are meaning a equals to A divided by A is equal to A divided by B. So that's what it means. So what is our A? Our A, it is actually 400 divided by 20. So it will give us the answer 20 now. And our last part of it, we are saying A, A modulus.

equals to B. So this is equivalent to what? This is equivalent by saying it is A equals to A modulus B. So A modulus B what will it be?

Our A is 20, modulus B which is 20, so the answer will be 0. So basically this is how it can be run. Basically we are putting up a printf on the putting up all our All our variables for assignment we had a one for assignment one for add and assign One for subtract and assign another one for multiple and assign another one for division and assign another one for modulus and assign So let's run and see what will be the outcome of this particular program. Yes when we run this particular program we are seeing that the first part of it we are getting up the assignment from 10 we are getting up the answer 20 the add assignment we're getting up 40 the sub assignment we're getting up 20 and the multiple time assignment we're getting up a 400 and the div assignment we're getting up 20 and the last one the mode assignment we are getting up zero so this will make up the end of our Question which you are had for the last four sessions What is the binary operator in our next session?

We are going to answer our last question. What? what are the tinary operators. So thank you very much for watching and remember to subscribe for more and new videos in our next lesson.