1
00:00:00,600 --> 00:00:01,780
Hello and welcome.

2
00:00:01,830 --> 00:00:12,180
In this lecture we are going to use the basic arithmetic operators in C sharp.

3
00:00:12,180 --> 00:00:17,130
So I mean the design view of our C sharp application.

4
00:00:17,130 --> 00:00:27,060
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

5
00:00:27,060 --> 00:00:35,790
back in to your design view and double click on the okay button if you double click on the okay button

6
00:00:35,910 --> 00:00:45,690
it will give you this it will show the code and you have the cursor flashing just where the okay button

7
00:00:45,720 --> 00:00:46,930
is just underneath.

8
00:00:47,070 --> 00:00:48,410
Okay.

9
00:00:48,420 --> 00:00:48,780
All right.

10
00:00:48,800 --> 00:00:54,570
So what we are going to do is write some code.

11
00:00:54,570 --> 00:01:03,040
We're going to declare some variables and we will use that to perform some arithmetic operations.

12
00:01:03,060 --> 00:01:03,450
All right.

13
00:01:03,450 --> 00:01:06,870
So before you declare variables you need to specify the type.

14
00:01:06,870 --> 00:01:11,840
So it's going to be an integer says classify it are code variable.

15
00:01:11,880 --> 00:01:18,680
I set the value to say 4.

16
00:01:19,830 --> 00:01:21,290
OK.

17
00:01:21,410 --> 00:01:28,930
Tab down create another variable again call this one J.

18
00:01:29,280 --> 00:01:32,720
Give it a value of C six

19
00:01:35,180 --> 00:01:40,210
or create another variable for to input the result.

20
00:01:41,590 --> 00:01:42,610
OK.

21
00:01:42,630 --> 00:01:44,860
Again it will be an integer.

22
00:01:45,440 --> 00:01:48,710
And the name of this variable will be result

23
00:01:51,950 --> 00:01:57,920
which will be equal to the value of i.

24
00:01:58,190 --> 00:02:05,320
Plus we using the operator now plus plus J.

25
00:02:05,420 --> 00:02:06,400
All right.

26
00:02:06,560 --> 00:02:17,890
So if I execute this code a should output 10 so I'll save it first whenever you see the yellow strip.

27
00:02:17,930 --> 00:02:23,450
It means he hasn't been saved actually to save and then run it.

28
00:02:23,460 --> 00:02:26,660
See what it does before run any code.

29
00:02:26,660 --> 00:02:33,800
I have decided to change the variable structure slightly so what I've done.

30
00:02:33,860 --> 00:02:39,910
Always good to write as little code as possible to try and achieve the same thing.

31
00:02:39,950 --> 00:02:47,210
So rather than these two lines I've just done the one line of code here declared the integer as the

32
00:02:47,240 --> 00:02:55,000
type set it to a variable i equals to four plus six rather than have two separate variables here.

33
00:02:55,010 --> 00:03:02,000
I've just had one and then made it four plus six and I've used the results label.

34
00:03:02,000 --> 00:03:09,740
Remember we created a resort label so in the resort label as a dot text or use the variable here which

35
00:03:09,740 --> 00:03:16,880
is an integer and I'm converting it to string using the two string method.

36
00:03:16,880 --> 00:03:25,900
All right so if I save this now and run this and that click on the okay button it should output 10.

37
00:03:26,030 --> 00:03:27,260
So let's give that a go

38
00:03:31,120 --> 00:03:32,370
so that's the okay button.

39
00:03:32,380 --> 00:03:35,700
If I click on that I expect tend to.

40
00:03:35,710 --> 00:03:36,250
There you go.

41
00:03:36,250 --> 00:03:45,880
So it's output at 10 from this code here because we've specified This integer will be that close stat.

42
00:03:45,880 --> 00:03:57,270
So that's where that result 10 came from someone established code and just change the operator symbol.

43
00:03:57,760 --> 00:04:00,270
I'm going to try to stop fraction.

44
00:04:01,050 --> 00:04:06,940
Operator I'm just changing the value slightly so to be 14 take away six.

45
00:04:07,060 --> 00:04:12,580
So I expect when you click on the okay button it will output the result.

46
00:04:12,580 --> 00:04:22,510
So I'll save that and our run the code if I click on the okay button I will express it.

47
00:04:22,630 --> 00:04:24,580
I will expect the value.

48
00:04:24,580 --> 00:04:33,200
So if you take away 14 from 6 it will output 8 x.

49
00:04:33,210 --> 00:04:42,820
I am going to try the most simply multiplication operator I'm just gonna change the operator sign there

50
00:04:43,600 --> 00:04:45,640
in C sharp multiplication.

51
00:04:45,640 --> 00:04:49,050
The same ball you do that with an asterix.

52
00:04:49,210 --> 00:04:57,600
So I'm going to change that to C seven seven times six.

53
00:04:57,640 --> 00:05:01,260
I'll make it seven times seven seven times seven.

54
00:05:01,510 --> 00:05:02,890
I save that.

55
00:05:03,100 --> 00:05:10,180
I'll expect it to output the result of seven times seven when I click on the okay button.

56
00:05:12,380 --> 00:05:13,710
So let's run the code.

57
00:05:13,720 --> 00:05:15,550
Click on that to run the code.

58
00:05:17,050 --> 00:05:21,890
So if I click on the code it should output the result of seven times seven.

59
00:05:21,890 --> 00:05:30,310
So I click okay and it's giving me forty nine which is the output you get from multiplying seven by

60
00:05:30,310 --> 00:05:32,030
seven.

61
00:05:32,130 --> 00:05:34,810
I'll stop the code and we'll try one more.

62
00:05:34,810 --> 00:05:39,880
Which is the division operator.

63
00:05:39,880 --> 00:05:41,960
So I'm going to change the value here.

64
00:05:42,080 --> 00:05:49,750
So number two changes in C sharp the way you you use a slash to indicate division.

65
00:05:49,750 --> 00:05:57,650
So I'm going to do twenty four divide by C four.

66
00:05:58,080 --> 00:06:02,280
I'll save that and execute the code.

67
00:06:04,380 --> 00:06:11,620
If I click on the okay button it should output the results so that you go when you divide 24 by four.

68
00:06:11,620 --> 00:06:13,850
It will give you six.

69
00:06:13,990 --> 00:06:15,250
That's what that says.

70
00:06:15,250 --> 00:06:16,080
All right.

71
00:06:16,120 --> 00:06:17,910
So I just click to stop that.

72
00:06:17,920 --> 00:06:27,940
So in this lecture we have used the basic operators to perform some very basic arithmetic functions

73
00:06:28,570 --> 00:06:34,340
in our next lecture we can look at the operator precedents see way.

74
00:06:34,360 --> 00:06:40,090
You have to use several of the operators together which one takes precedence.

75
00:06:40,090 --> 00:06:43,870
We're going to explore that in our next lecture for now.

76
00:06:43,900 --> 00:06:45,280
Thanks for watching.

77
00:06:45,280 --> 00:06:46,110
Bye for now.
