Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,490 --> 00:00:01,640
What is going on, guys?
2
00:00:01,680 --> 00:00:08,050
And welcome back to another exercise in our amazing programming course.
3
00:00:08,770 --> 00:00:15,970
And in this exercise, what we are going to do is simply to write a program that will receive a number
4
00:00:15,970 --> 00:00:23,360
with three digits, and this program should calculate the sum of digits in this number.
5
00:00:23,740 --> 00:00:29,740
So, for example, we will be given with a number with, say, Litz integer number with three digits.
6
00:00:29,740 --> 00:00:36,280
And all that we have to do is to find what will be the sum of all of its digits.
7
00:00:36,580 --> 00:00:40,690
So, for example, we have numbers five hundred and thirty one.
8
00:00:41,350 --> 00:00:49,450
Then we know we can calculate it just by summing up five plus three plus one, which will give us a
9
00:00:49,450 --> 00:00:50,980
total of nine.
10
00:00:51,140 --> 00:01:00,220
OK, so simply taking, simply taking all of the digits, five, three one for example, the units,
11
00:01:00,220 --> 00:01:08,110
the tenth and hundreds summing them up together and returning, basically printing the result to the
12
00:01:08,110 --> 00:01:08,560
screen.
13
00:01:08,650 --> 00:01:16,210
OK, nothing complicated actually of the main thing that you have to bear in mind is just how you're
14
00:01:16,210 --> 00:01:19,390
getting any one of the digits.
15
00:01:19,420 --> 00:01:26,710
OK, so there should be a rule that you should apply to get the units, which is one to get the 10th,
16
00:01:26,710 --> 00:01:30,760
which is three and to get five, which is the hundreds.
17
00:01:30,780 --> 00:01:37,360
OK, so the numbers just know that all the numbers that this program should support is just numbers
18
00:01:37,480 --> 00:01:39,440
with three digits.
19
00:01:39,460 --> 00:01:47,200
OK, basically we will not even add some testing, some condition to make sure that this number is actually
20
00:01:47,380 --> 00:01:48,720
with three digits.
21
00:01:48,730 --> 00:01:56,830
We will simply assume that the user will read our descriptive message and it he will treat this information
22
00:01:56,830 --> 00:02:03,570
and he will insert he or she, of course, will insert a value with three digits.
23
00:02:03,580 --> 00:02:07,560
So then we can work with it and sum up all the digits.
24
00:02:07,990 --> 00:02:13,910
So give it a shot of your own if you have any questions so far before seeing the solution.
25
00:02:14,200 --> 00:02:18,370
Also, feel free to ask them and let's get to work.
2696
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.