Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,270 --> 00:00:01,620
All right, welcome back, guys.
2
00:00:01,650 --> 00:00:03,780
So in this video, we are going through, right?
3
00:00:04,030 --> 00:00:08,820
Simple example, a simple example for a function in C programming language.
4
00:00:08,940 --> 00:00:14,970
So these functions should basically be some reading function that only does the Toli does.
5
00:00:14,970 --> 00:00:22,230
It's just a reading function, reading function that all he does is simply running some print F commands.
6
00:00:22,380 --> 00:00:23,610
And this function.
7
00:00:23,640 --> 00:00:28,840
All he does is simply to to do what's to, let's say, printing.
8
00:00:28,890 --> 00:00:29,580
Hello.
9
00:00:29,880 --> 00:00:31,830
This will be printed out on the first line.
10
00:00:32,160 --> 00:00:33,990
And the second line we will have.
11
00:00:34,290 --> 00:00:38,790
Welcome to the best course ever.
12
00:00:38,910 --> 00:00:42,690
Right ever in C programming.
13
00:00:42,750 --> 00:00:44,520
Programming language.
14
00:00:44,640 --> 00:00:46,320
This will be the second line.
15
00:00:46,710 --> 00:00:52,380
And on the third line, our function will bring something like a good luck message.
16
00:00:52,880 --> 00:00:53,280
All right.
17
00:00:53,310 --> 00:00:58,470
So all these function will do is simply to run, to execute, to print on the screen.
18
00:00:58,800 --> 00:01:02,340
These three lines of information.
19
00:01:02,600 --> 00:01:06,010
So the function is going to be with no parameters.
20
00:01:06,030 --> 00:01:07,440
It will not get.
21
00:01:07,470 --> 00:01:09,780
It will not expect to receive any parameters.
22
00:01:09,810 --> 00:01:11,580
And it will not return anything.
23
00:01:11,880 --> 00:01:15,270
It will simply be like a guy that you just call him.
24
00:01:15,390 --> 00:01:17,310
You don't pass him anything.
25
00:01:17,730 --> 00:01:22,170
And also, you do not expect to receive anything in return.
26
00:01:22,320 --> 00:01:23,490
You simply call him.
27
00:01:23,520 --> 00:01:26,280
And all he does is to print something to the screen.
28
00:01:26,280 --> 00:01:32,880
And you know that once this guy is over with his task, that, you know, its task is simply to bring
29
00:01:32,880 --> 00:01:34,350
something to your screen.
30
00:01:34,840 --> 00:01:36,990
What once he's done with these tasks.
31
00:01:37,130 --> 00:01:39,150
You can move on to the next commands.
32
00:01:39,270 --> 00:01:43,260
So let's see how our signature for this function will look like.
33
00:01:43,290 --> 00:01:43,670
All right.
34
00:01:43,680 --> 00:01:48,000
So first of all, we know that this function will not return anything.
35
00:01:48,120 --> 00:01:54,960
So the type of the function we said previously is going to be of not an integer, not a double, not
36
00:01:54,960 --> 00:01:57,840
a double, not a char or nothing like that.
37
00:01:58,020 --> 00:02:04,770
The type of the function is going to be specified as Avoid the Void says that we will not expect to
38
00:02:04,770 --> 00:02:09,420
receive anything in return are once the function has been.
39
00:02:10,350 --> 00:02:12,930
As it has ran all of its commands.
40
00:02:13,050 --> 00:02:17,280
And then we are going to to specify the function name.
41
00:02:17,280 --> 00:02:19,430
So we will go like preened.
42
00:02:19,470 --> 00:02:20,060
Let's go.
43
00:02:20,070 --> 00:02:21,270
Preened readings.
44
00:02:21,540 --> 00:02:21,770
Right.
45
00:02:21,900 --> 00:02:23,010
Print reading.
46
00:02:23,100 --> 00:02:24,280
Let's say print greetings.
47
00:02:24,290 --> 00:02:25,140
Bring greetings.
48
00:02:25,200 --> 00:02:25,620
All right.
49
00:02:25,890 --> 00:02:27,390
So this is the functions name.
50
00:02:27,420 --> 00:02:28,080
This is what.
51
00:02:28,350 --> 00:02:29,100
The function.
52
00:02:29,360 --> 00:02:29,900
The function.
53
00:02:29,900 --> 00:02:31,800
Stipe and this is the function name.
54
00:02:31,950 --> 00:02:36,710
And now we know that the function will not expect to get any parameters.
55
00:02:36,780 --> 00:02:40,740
So we'll just use empty parentheses here.
56
00:02:40,980 --> 00:02:43,860
And we will not specify anything in this.
57
00:02:43,930 --> 00:02:46,410
Are borage so far or signature?
58
00:02:46,560 --> 00:02:52,140
So now what we've created is a simple function that for now it does not has anything.
59
00:02:52,140 --> 00:02:53,480
It does not contain anything.
60
00:02:53,820 --> 00:02:56,310
And what we would like to do next.
61
00:02:56,340 --> 00:02:58,280
This is specified the function body.
62
00:02:58,290 --> 00:03:00,450
So it will go with these curly brackets.
63
00:03:00,600 --> 00:03:07,080
And now everything that is going to be between these curly brackets is going to be a part of these preening
64
00:03:07,620 --> 00:03:09,560
print greetings function.
65
00:03:09,990 --> 00:03:13,580
So we are going to specify the first print of command.
66
00:03:13,620 --> 00:03:15,420
So it's just like hello.
67
00:03:16,380 --> 00:03:17,100
And a backslash.
68
00:03:17,100 --> 00:03:23,400
And at the end, although we could just use all of these attacks to print it out in just one print of
69
00:03:23,400 --> 00:03:29,190
command by specifying that the correct places the backslash and we are going to divided the three print
70
00:03:29,190 --> 00:03:30,840
of command commands.
71
00:03:30,930 --> 00:03:34,200
So it will be just more nice for us to see.
72
00:03:34,320 --> 00:03:39,780
So for the second print F line, we are going to use Spring Springtown and we are going let's just copy
73
00:03:39,780 --> 00:03:43,400
and paste this line, going to base it here.
74
00:03:43,440 --> 00:03:45,890
So backslash n at the end, semicolon.
75
00:03:46,260 --> 00:03:47,460
And there you go.
76
00:03:47,790 --> 00:03:56,300
So now now we are going to use also the third line, which is just a print half good, large message.
77
00:03:57,400 --> 00:03:58,680
The last message.
78
00:03:58,710 --> 00:04:00,240
And that's it.
79
00:04:00,440 --> 00:04:01,970
This should be like this.
80
00:04:02,090 --> 00:04:03,220
It looks nice, right?
81
00:04:03,650 --> 00:04:08,400
And now what I want us to do is to understand what we can see here.
82
00:04:08,430 --> 00:04:14,400
So once again, what we've done right now, we didn't run these function.
83
00:04:14,490 --> 00:04:17,250
We just created a template of a function.
84
00:04:17,310 --> 00:04:19,110
We just created the function itself.
85
00:04:19,380 --> 00:04:20,620
It's not being run.
86
00:04:20,970 --> 00:04:27,810
If we just if if we even build and run this program right now, these messages are not going to be seen
87
00:04:27,810 --> 00:04:28,590
on your screen.
88
00:04:29,010 --> 00:04:30,170
So you may even try it.
89
00:04:30,210 --> 00:04:30,990
Let's do it.
90
00:04:31,050 --> 00:04:31,560
Let's go.
91
00:04:31,560 --> 00:04:33,370
Like we're running it.
92
00:04:33,390 --> 00:04:36,510
And you can see that nothing nothing happens, right?
93
00:04:36,720 --> 00:04:38,180
Because we run the INS.
94
00:04:38,190 --> 00:04:38,440
Me.
95
00:04:38,520 --> 00:04:39,720
This is the entry point.
96
00:04:40,020 --> 00:04:42,270
We run this command, return zero.
97
00:04:42,420 --> 00:04:46,380
We actually do not do anything here in this main function.
98
00:04:46,660 --> 00:04:47,550
And that's it.
99
00:04:48,000 --> 00:04:50,310
So we simply created some guy.
100
00:04:50,340 --> 00:04:57,750
Let's say that he his name is print greetings and he does not expect to receive anything.
101
00:04:57,780 --> 00:04:59,370
No parameter is specified.
102
00:05:00,060 --> 00:05:04,560
And we will call him, we will not expect that he will return something.
103
00:05:04,770 --> 00:05:11,050
But all he all he does is simply to run these three print F comments, to print some information to
104
00:05:11,050 --> 00:05:11,580
the screen.
105
00:05:11,800 --> 00:05:13,590
And what interests us here.
106
00:05:13,650 --> 00:05:14,010
Right.
107
00:05:14,080 --> 00:05:15,810
We we created this function.
108
00:05:15,840 --> 00:05:17,910
We want to call this function.
109
00:05:17,910 --> 00:05:20,520
Want to rohn's these functions somehow.
110
00:05:20,640 --> 00:05:28,170
So for that, we're going to come back here at the end main function and we know that we can call every
111
00:05:28,170 --> 00:05:29,670
function by its name.
112
00:05:29,670 --> 00:05:30,020
Right.
113
00:05:30,030 --> 00:05:31,260
And the name is print.
114
00:05:31,310 --> 00:05:31,890
Greetings.
115
00:05:31,920 --> 00:05:34,620
So let's try to write down print.
116
00:05:35,280 --> 00:05:36,210
Greetings.
117
00:05:36,240 --> 00:05:37,740
Print greetings.
118
00:05:38,300 --> 00:05:39,030
Write print.
119
00:05:39,060 --> 00:05:39,750
Greetings.
120
00:05:40,440 --> 00:05:45,450
And we specify VMT parenthesis here and just semicolon at the end.
121
00:05:45,540 --> 00:05:47,960
So let's see what happens in this kit.
122
00:05:48,050 --> 00:05:50,910
In this case, let's build and run it.
123
00:05:51,080 --> 00:05:51,390
Oh.
124
00:05:51,420 --> 00:05:52,020
And there you go.
125
00:05:52,030 --> 00:05:55,290
You can see that all of the message was printed on the screen.
126
00:05:55,290 --> 00:05:58,630
The Hello, the welcome to the best chorusing C programming language.
127
00:05:59,040 --> 00:06:00,270
And a good luck message.
128
00:06:00,390 --> 00:06:04,350
So basically all the information of these function was printed out.
129
00:06:04,890 --> 00:06:06,780
So let's see what happened here.
130
00:06:06,810 --> 00:06:09,660
We, first of all, came to the entry point to the main.
131
00:06:10,300 --> 00:06:14,190
Then we started to execute the there these function body.
132
00:06:14,190 --> 00:06:14,450
Right.
133
00:06:14,460 --> 00:06:17,250
The first command and then the second and the third one and so on.
134
00:06:17,550 --> 00:06:25,320
So when we when we saw these print greetings, we know that you can see it in the red, that once you
135
00:06:25,320 --> 00:06:29,410
write the functions name, you are going to execute this function.
136
00:06:29,430 --> 00:06:33,120
We know that the function does not expect to receive any parameters.
137
00:06:33,180 --> 00:06:37,120
So we do not send to these function any arguments.
138
00:06:37,140 --> 00:06:37,350
Right.
139
00:06:37,370 --> 00:06:42,900
You send arguments and the function receive it as the parameters and also the function does not return
140
00:06:42,900 --> 00:06:43,350
anything.
141
00:06:43,590 --> 00:06:45,360
So we just called the function.
142
00:06:45,360 --> 00:06:50,250
We say, hey, print greetings guy, do your job and print everything to the screen.
143
00:06:50,610 --> 00:06:51,600
And there you go.
144
00:06:51,630 --> 00:06:54,660
So this is this command is the first one to be executed.
145
00:06:54,960 --> 00:06:56,550
And then you go like this.
146
00:06:56,550 --> 00:06:57,620
You print these line.
147
00:06:57,940 --> 00:06:58,700
Then this line.
148
00:06:58,740 --> 00:06:59,490
Then this line.
149
00:06:59,790 --> 00:07:03,930
Then you come for the next to the last line in this function.
150
00:07:04,410 --> 00:07:12,270
And once the function is done, running all of its commands, you are going to come back here, here,
151
00:07:12,690 --> 00:07:16,500
and you are going to proceed with this function.
152
00:07:16,680 --> 00:07:17,070
All right.
153
00:07:17,100 --> 00:07:20,580
Within my next line with line number 19.
154
00:07:20,670 --> 00:07:26,970
And very you go you basically will the return zero in your program is overeats complete.
155
00:07:27,060 --> 00:07:33,660
So I hope this makes sounds how you create a function function of type void that does not supposed to
156
00:07:33,660 --> 00:07:34,860
return anything.
157
00:07:35,010 --> 00:07:36,050
No parameters.
158
00:07:36,210 --> 00:07:40,560
You call this function here and basically let's listen and see.
159
00:07:40,560 --> 00:07:41,860
Let's add another align.
160
00:07:41,880 --> 00:07:44,280
Let's say pretend to have an.
161
00:07:44,550 --> 00:07:45,420
Hello.
162
00:07:46,950 --> 00:07:50,310
Let's say hello to this program.
163
00:07:51,470 --> 00:07:57,020
I'm writing from from main function.
164
00:07:57,380 --> 00:07:57,700
Okay.
165
00:07:57,990 --> 00:08:01,950
So this message is going to be printed out from the main function.
166
00:08:02,040 --> 00:08:07,680
And once it's printed out, we are going to call these function or print readings function.
167
00:08:08,010 --> 00:08:10,110
All of its commands are going to be executed.
168
00:08:10,350 --> 00:08:15,720
And then we are going to come back here and say, let's say just just that you will see the difference
169
00:08:15,720 --> 00:08:16,800
in how the flow goes.
170
00:08:18,240 --> 00:08:22,050
Now, I am after the function.
171
00:08:23,160 --> 00:08:24,420
Also at main.
172
00:08:24,720 --> 00:08:26,480
Also at Main.
173
00:08:26,750 --> 00:08:27,020
Okay.
174
00:08:27,660 --> 00:08:31,560
And we will add a backslash and the and the semicolon at the end.
175
00:08:31,710 --> 00:08:34,860
So now if we build and run it, let's see what happens.
176
00:08:34,950 --> 00:08:35,370
All right.
177
00:08:35,490 --> 00:08:37,440
Oh, we have the message here.
178
00:08:37,440 --> 00:08:37,680
Why.
179
00:08:37,680 --> 00:08:38,690
What is the problem?
180
00:08:38,830 --> 00:08:40,650
I got a semicolon in the end.
181
00:08:40,980 --> 00:08:42,180
Don't forget a semicolon.
182
00:08:42,330 --> 00:08:45,210
Otherwise, bad things may happen.
183
00:08:45,300 --> 00:08:46,500
So let's run it.
184
00:08:46,710 --> 00:08:47,560
And there you go.
185
00:08:47,580 --> 00:08:52,140
You can see that the first message is hello, this hello to this program.
186
00:08:52,140 --> 00:08:53,940
I'm writing from main function.
187
00:08:54,300 --> 00:08:59,730
And once in these messages printed out all the functional body of the print.
188
00:08:59,760 --> 00:09:00,230
Greetings.
189
00:09:00,760 --> 00:09:02,950
I am of the print greetings.
190
00:09:03,420 --> 00:09:05,190
Function is being executed.
191
00:09:05,580 --> 00:09:09,410
And then we have it was like one, two and good luck.
192
00:09:09,510 --> 00:09:11,910
Oh, I didn't specify backslash and at this function.
193
00:09:12,210 --> 00:09:13,260
Let me see.
194
00:09:13,270 --> 00:09:13,940
Let me check out.
195
00:09:14,670 --> 00:09:15,390
There you go.
196
00:09:15,420 --> 00:09:20,790
You should also specify because Lashan and once these functions is over, we are going to proceed with
197
00:09:20,790 --> 00:09:24,330
this line after all of these lines were printed out on the screen.
198
00:09:24,400 --> 00:09:27,810
Who so this this was not so easy.
199
00:09:27,840 --> 00:09:33,450
But I think you've got the idea we create a function and then we can call this function.
200
00:09:33,600 --> 00:09:36,510
So this is it, for example, number one.
201
00:09:36,780 --> 00:09:40,050
And let us proceed with the second example.
16032
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.