Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:05,430 --> 00:00:07,210
Hello, and welcome to
your first challenge.
2
00:00:07,210 --> 00:00:10,330
This is going to be a rather easy
challenge for storage classes.
3
00:00:10,330 --> 00:00:11,409
I provided a quiz.
4
00:00:12,349 --> 00:00:15,789
The storage classes are kind of tough
to have programming, exercise in
5
00:00:15,790 --> 00:00:18,490
there that do anything real relevant.
6
00:00:18,490 --> 00:00:20,810
So these are just
some easy challenges.
7
00:00:21,360 --> 00:00:22,970
I'm going to provide you
with three challenges.
8
00:00:23,390 --> 00:00:25,970
They're really small, but
they will help you better
9
00:00:25,970 --> 00:00:27,680
understand storage classes in c.
10
00:00:28,189 --> 00:00:30,779
And as I mentioned, they're quite
easy, so they shouldn't take too long.
11
00:00:31,400 --> 00:00:34,290
The first challenge that I want you
to write is just a small program that
12
00:00:34,290 --> 00:00:35,669
really just declares some variables.
13
00:00:36,190 --> 00:00:40,120
I want you to declare some variables
with specific storage class
14
00:00:40,160 --> 00:00:41,530
specifiers that you need to use.
15
00:00:42,170 --> 00:00:44,999
So for example, you have to clear an
invariable block scope in temporary
16
00:00:45,000 --> 00:00:48,820
storage, global double variable that
is only accessible inside the file.
17
00:00:49,440 --> 00:00:51,789
Float variable that's global,
accessible throughout
18
00:00:51,790 --> 00:00:52,720
the entire program.
19
00:00:53,299 --> 00:00:56,809
A float local variable with permanent
storage, a register int variable and
20
00:00:56,810 --> 00:01:00,239
a function that is only accessible
within the file that is defined.
21
00:01:00,550 --> 00:01:01,599
So pretty straightforward.
22
00:01:01,600 --> 00:01:04,100
If you understand the storage
class specifiers, this is
23
00:01:04,100 --> 00:01:05,710
going to be very easy to do.
24
00:01:06,250 --> 00:01:09,509
Our second challenge is you're
going to have to write a c program
25
00:01:09,509 --> 00:01:11,749
that finds the sum of a number.
26
00:01:12,129 --> 00:01:14,380
It's really just going to
retain its value for each call.
27
00:01:14,860 --> 00:01:18,820
So you can't pass any variable
representing the running
28
00:01:18,820 --> 00:01:21,390
total to the sum function,
so it can't take a parameter.
29
00:01:21,789 --> 00:01:25,580
It just takes one parameter for
what you want to sum, what you
30
00:01:25,580 --> 00:01:27,029
want to add to the previous total.
31
00:01:27,490 --> 00:01:29,440
So it'll just be a sum
function take some number.
32
00:01:29,840 --> 00:01:31,850
You'll find the sum of a
number from the previous call.
33
00:01:31,880 --> 00:01:33,480
So you'll see this
example in the output.
34
00:01:33,950 --> 00:01:37,460
So for example if I call sum
three times passing in 25 15
35
00:01:37,660 --> 00:01:41,550
and 30, the output is actually
going to be 25 the first time,
36
00:01:42,130 --> 00:01:44,709
40 the second time and 70 third.
37
00:01:45,289 --> 00:01:48,319
So each time you call it it's
summing that number that's
38
00:01:48,330 --> 00:01:49,860
passed in from the previous sum.
39
00:01:50,380 --> 00:01:54,089
So you have to use the storage
class specifier to implement this.
40
00:01:55,080 --> 00:01:58,070
The third challenge is you're gonna
need to create a c program that
41
00:01:58,070 --> 00:02:00,310
shares a variable amongst two files.
42
00:02:00,840 --> 00:02:02,980
So create a source file named main.c.
43
00:02:03,490 --> 00:02:06,400
The source file should include a
globe variable used as a loop counter.
44
00:02:06,940 --> 00:02:10,340
This file includes a main function
that uses the global variable to
45
00:02:10,340 --> 00:02:11,610
iterate through a loop five times.
46
00:02:12,250 --> 00:02:14,890
Inside this loop a function
should be invoked, something
47
00:02:14,890 --> 00:02:18,790
like a display function that
is defined in another file and
48
00:02:18,790 --> 00:02:20,380
you cannot use an include file.
49
00:02:20,380 --> 00:02:23,160
The display function
should take two parameters.
50
00:02:24,150 --> 00:02:28,549
And then in the other file display.c,
this is where the display function
51
00:02:28,550 --> 00:02:32,130
is defined and this function
will display the global variable
52
00:02:32,130 --> 00:02:34,460
from main.c incremented by one.
53
00:02:34,780 --> 00:02:36,829
So since these are pretty
easy, I'm not going to actually
54
00:02:36,830 --> 00:02:38,210
have an entire demonstration.
55
00:02:38,540 --> 00:02:41,269
I'm going to provide you
with the source files in
56
00:02:41,270 --> 00:02:44,420
this lecture containing the
source code for solutions.
57
00:02:44,760 --> 00:02:46,489
If you have any questions,
please let me know.
58
00:02:46,860 --> 00:02:50,390
But again, these are rather easy
challenges with easy solutions.
59
00:02:50,390 --> 00:02:52,860
So I don't think there's -- it's
necessary to provide an
60
00:02:52,860 --> 00:02:53,839
entire demonstration.
61
00:02:54,730 --> 00:02:55,350
Thank you.
5415
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.