Hello and welcome.
In this lecture we are going to use the basic arithmetic operators in C sharp.
So I mean the design view of our C sharp application.
I'm just going to click on make sure you've got the s clicked s default dot is X not see us then go
back in to your design view and double click on the okay button if you double click on the okay button
it will give you this it will show the code and you have the cursor flashing just where the okay button
is just underneath.
Okay.
All right.
So what we are going to do is write some code.
We're going to declare some variables and we will use that to perform some arithmetic operations.
All right.
So before you declare variables you need to specify the type.
So it's going to be an integer says classify it are code variable.
I set the value to say 4.
OK.
Tab down create another variable again call this one J.
Give it a value of C six
or create another variable for to input the result.
OK.
Again it will be an integer.
And the name of this variable will be result
which will be equal to the value of i.
Plus we using the operator now plus plus J.
All right.
So if I execute this code a should output 10 so I'll save it first whenever you see the yellow strip.
It means he hasn't been saved actually to save and then run it.
See what it does before run any code.
I have decided to change the variable structure slightly so what I've done.
Always good to write as little code as possible to try and achieve the same thing.
So rather than these two lines I've just done the one line of code here declared the integer as the
type set it to a variable i equals to four plus six rather than have two separate variables here.
I've just had one and then made it four plus six and I've used the results label.
Remember we created a resort label so in the resort label as a dot text or use the variable here which
is an integer and I'm converting it to string using the two string method.
All right so if I save this now and run this and that click on the okay button it should output 10.
So let's give that a go
so that's the okay button.
If I click on that I expect tend to.
There you go.
So it's output at 10 from this code here because we've specified This integer will be that close stat.
So that's where that result 10 came from someone established code and just change the operator symbol.
I'm going to try to stop fraction.
Operator I'm just changing the value slightly so to be 14 take away six.
So I expect when you click on the okay button it will output the result.
So I'll save that and our run the code if I click on the okay button I will express it.
I will expect the value.
So if you take away 14 from 6 it will output 8 x.
I am going to try the most simply multiplication operator I'm just gonna change the operator sign there
in C sharp multiplication.
The same ball you do that with an asterix.
So I'm going to change that to C seven seven times six.
I'll make it seven times seven seven times seven.
I save that.
I'll expect it to output the result of seven times seven when I click on the okay button.
So let's run the code.
Click on that to run the code.
So if I click on the code it should output the result of seven times seven.
So I click okay and it's giving me forty nine which is the output you get from multiplying seven by
seven.
I'll stop the code and we'll try one more.
Which is the division operator.
So I'm going to change the value here.
So number two changes in C sharp the way you you use a slash to indicate division.
So I'm going to do twenty four divide by C four.
I'll save that and execute the code.
If I click on the okay button it should output the results so that you go when you divide 24 by four.
It will give you six.
That's what that says.
All right.
So I just click to stop that.
So in this lecture we have used the basic operators to perform some very basic arithmetic functions
in our next lecture we can look at the operator precedents see way.
You have to use several of the operators together which one takes precedence.
We're going to explore that in our next lecture for now.
Thanks for watching.
Bye for now.