Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Welcome back.
And in this video, we are going to solve the challenge of printing out in isosceles triangle using
asterisks.
So an asterisk is just like a character that you can print on your screen, just like you printed out
the letter or characters of Hello World Message.
So similarly can be done here.
So to solve that in the first way, we can just use three print of commands, right.
So on the first line to print one asterisk, we will use printer and print out one asterisk.
And also add a backslash.
And at the end, on the second line, we will print three of them.
Right.
One, two, three.
Add a backslash and add the same for the third line.
Right.
We're using multiple print F commands.
So one, two, three, four, five.
And the backslash.
And there you go.
So now if we are to build and run this program, we will see these triangular right here.
And we can see that it's not exactly what we wanted.
Right.
Although that's a triangle.
We should reorder there with a little bit.
And that's why the main thing in this exercise is to notice how how we can use correctly these lines,
spacing between these asterisks and how we can use the backslash and the new lines here correctly.
So, first of all, to place the asterisk.
And the first line at the center of the triangle, we will just add two line spaces here and before
the asterisk and two lines business afterwards.
So there will be a total of five characters just like we have at the base.
Then we would like to move the three asterisks here.
OK.
And the second line to the Medo and we can do that by just adding one line space before and one line
space after.
And you can see that right now it starts to make some form the actual form that we wanted it to be.
So on the third line will live it as sees no line spaces, no line spaces actually are needed here.
We already got our five characters at the base, as it should be.
And now let's run it.
Guys, let's build and run.
And there you go.
And isosceles triangle of asterisk, exactly as requested.
Good job.
So the biggest trick here in these exercises to properly use these lines, bases and the new line as
we explain here.
And now, once you've got some experience with that, let's try printing goal of this, try and going
just one print off-line.
So, first of all, let's clean all of this.
Right.
And now we will start just like with the previous example in 3-D.
The first line using these two spaces before and after these Suan asterisks.
So print here, add two spaces, add one asterisk and add two other spaces.
Now that center, then let's add the backslash and to go to the next line.
Then instead of using another print of command, we'll just add the second line because we will already
be on the second line.
Thanks to these Becs Lashan.
Right.
And here we'll use just one space line and then the three asterisks.
So once baseline three asterisk, another space line and a backslash and at the end to go one line down.
Now we can print five of them at the base at the last line and add the last backslash Lashan.
And of course, a semicolon at the end.
And one thing I forgot to do is to return zero.
And hopefully we did everything right.
Let's try to build and run it and very go.
It works like charm.
Basically, it's just the same as we've seen previously when we use their three printf lines.
OK, the three printf commands jazz that right now we've used it in one print command.
So that's a good practice for these radio guys and for these exercises.
And one less thing for this video.
Before we finish this exercise, I would like to ask you a question to think about and try to solve
it on your own.
We've used the different number of line spaces before this sequence of fast rescreen every line.
And also, we've used the same number of spaces of line spaces right after the sequence at every line.
All right.
So we can see it right here.
And there are spaces are right after the asterisk as well as here.
So the question is, do we actually need it?
Do we need these spaces right after we've written a sequence of asterisks?
Or maybe we can simply put a backslash in right after.
And we'll be good.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.