WEBVTT 00:06.140 --> 00:11.630 In this lecture, I'm going to show you how to create a simple multiplication table using nested loops. 00:12.790 --> 00:17.470 This example will provide a basis for the slightly more advanced upcoming lecture. 00:18.440 --> 00:25.040 If you noticed, increasing the complexity of the subjects that I'm talking about, step by step, this 00:25.040 --> 00:27.130 will continue till the end of the class. 00:27.860 --> 00:29.090 OK, now let's get started. 00:30.880 --> 00:34.930 Now I'm going to show you what the multiplication table will look like at the end. 00:41.310 --> 00:46.680 Of course, in the common line, it won't look as shiny as this, although you can do it with the help 00:46.680 --> 00:50.820 of a little bit of comment line magic, but it would be an overkill for now. 00:50.820 --> 00:53.370 So our multiplication table will be colorless. 00:54.300 --> 00:57.380 Now, let's learn how to build this program step by step. 00:58.320 --> 01:00.900 Now I'm going to show you how to create the header first. 01:02.420 --> 01:04.460 Let's take a look at this in the ED. 01:06.380 --> 01:12.440 OK, let's first print the X letter like this, if umpty printf person fifes. 01:13.590 --> 01:22.030 X. OK, I typed this person five s were like this, so it will be five characters white, OK, five 01:22.050 --> 01:27.030 years sets the printing waits for this verb so the print F. will print four spaces. 01:27.180 --> 01:31.680 Then it will print the X character this way that X will be aligned to the right. 01:32.560 --> 01:43.530 OK, ok, now let's create a loop or printing the numbers for I zero ai less than an equal to five increment 01:43.530 --> 01:43.860 I. 01:44.500 --> 01:46.440 OK now I'm going to print the numbers. 01:47.380 --> 01:50.620 Printf percent five The and I. 01:52.360 --> 01:57.440 OK, now let's print another new line here to separate the rest of the table from this other. 01:57.610 --> 01:57.970 OK. 01:58.780 --> 01:59.290 All right. 01:59.300 --> 02:00.250 The Heather is right. 02:00.280 --> 02:01.330 Now, let me run it. 02:03.750 --> 02:08.940 It looks good to me, as you can see, X and the each number here are five characters. 02:08.940 --> 02:12.690 What this why are used five in the printf just before. 02:13.260 --> 02:15.300 So the line here beautifully. 02:16.780 --> 02:21.440 By the way, while in here, let's make this magical number five constant. 02:21.460 --> 02:24.520 OK, I'm going to use it a few times in the card. 02:25.750 --> 02:26.800 All right, brother. 02:30.620 --> 02:33.050 Now it's time to create this column on the left. 02:35.750 --> 02:38.070 OK, let's take a look at this in the editor again. 02:40.980 --> 02:46.020 All right, now I'm going to type another loop here to print the vertical column like this. 02:50.260 --> 02:55.200 Inside, I'm going to print a number like this using the five again. 02:56.430 --> 03:00.510 OK, since this is a vertical column, so I'm going to print another new line here. 03:02.600 --> 03:08.840 All right, you might ask why I didn't type this new line inside the printer directly, you will see 03:08.840 --> 03:10.050 why in the next step. 03:10.090 --> 03:10.430 OK. 03:11.580 --> 03:13.910 OK, now let's take a look at the table again. 03:15.230 --> 03:16.360 I think it looks good. 03:18.950 --> 03:20.210 Heather's off the table. 03:20.400 --> 03:26.480 OK, now it's time to create the inner circles of this table where the real multiplication will happen. 03:28.030 --> 03:32.920 This is where the next loop comes into the scene inside the loop. 03:33.070 --> 03:39.250 I'm going to create another loop and loop and inside the nested loop, I'm going to multiply the numbers 03:39.250 --> 03:42.220 to create the inner cells of the multiplication table. 03:43.220 --> 03:45.800 All right, let's take a look at it in the according Ed. 03:47.980 --> 03:52.230 Now, I'm going to create the nicest loop in here right inside the loop. 03:54.630 --> 03:56.730 Now I'm going to loop four or five times again. 04:00.810 --> 04:06.910 OK, now I'm going to print the inner circle of the table again with five words verb. 04:07.350 --> 04:10.530 Now I need to print the multiplication like this. 04:11.040 --> 04:12.480 I multiplied by. 04:13.960 --> 04:20.290 This is why this printer was here, by the way, after each it prints a new line, Rembrandts. 04:22.590 --> 04:24.960 As you can see now, it's done great. 04:25.500 --> 04:26.640 Let's check the results. 04:27.240 --> 04:34.950 For example, three multiplied by three is nine, four multiplied, four is sixteen, five multiplied 04:34.950 --> 04:35.610 by five. 04:35.610 --> 04:36.240 Twenty five. 04:36.630 --> 04:38.070 It works the correct. 04:42.390 --> 04:45.720 All right, our multiplication table is ready, cool. 04:56.160 --> 04:56.970 Now it's your turn. 04:57.330 --> 05:03.690 Here are a few challenges for you create a dynamic table by getting the size of the multiplication table 05:03.690 --> 05:08.520 from the command line as an argument, you would need to convert it to a number, of course. 05:09.570 --> 05:15.480 Then, for example, if the user passes five as an argument, then you will create them five x five 05:15.480 --> 05:21.300 multiplication table or the user passes 10 than the table size will be 10x that. 05:22.170 --> 05:28.110 As a bonus, exercise creates more tables like four division addition and subtraction. 05:28.500 --> 05:30.660 You can create separate programs for each one. 05:30.750 --> 05:31.290 Good luck. 05:31.950 --> 05:33.160 But that's all for now. 05:33.690 --> 05:35.240 See in the next picture, my.