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
So basically, we were asked to write a program that will get as an input from the user to variables
current year end users age and then make some calculations on these two variables.
But let's leave that aside for now and just focus on the first part.
We need to get as an input to values for our two variables.
And then the previous videos, we've said that if we wanted to use variables in our program, then the
first step to do is to create them, to declare them.
So that's exactly what we're going to do right now.
So let's first of all, declare these two variables gained current year.
Right.
It's the first variable.
And let's declare also the age variable int age.
Both of them are of type integer.
The first name is current year and the second name is age.
So at this point, these two variables are kind of empty.
They contain no real value at this point.
And one of the options to set their values is to use assignment and to give these values.
I don't know something manually, for example.
We can use current year, current year equals to 2020 and age equals to 30, as we used in our example.
And that's exactly what we don't want to do.
We should read these values from the user and not to sign them manually as we're doing here.
So the first thing that we do is scan F, scan F, all right.
Percentage the Y because we use two variables of type.
And then we use a comma ampersand and current current year.
Right.
That's how we scan F as an input from the user.
The current year.
And also let's do the same for the age scan of percentage.
The ampersand age.
This once again, once again means the address where the variable age resides.
All right.
So take the value from the prompt from the console application, read it and put it inside of these
variable.
All right.
So in this way, we'll be able to read these values from the user.
So there are different.
Users will be able to insert different values in a more generic way.
So now at this point, at this line, at this line, for example, line twelve, after the two scan
F lines and all that remains now is to calculate and print the results, to print the year you were
born to the screen.
So to bring something to the screen, we should use the print.
The print if function.
Right.
Print F.
All right.
So what should be we should we be printing for this screen.
So we should be printing something like that.
You were born in percentage the backslash n right.
To get one line down.
And here we should use our expression to find out the exact year that you were born.
And that could be done just by subtracting can be current.
The age of the current year, current year minus age will give us the exact year that the user were
born, was born.
And there you go.
Now we can build and run this program and see their results on the screen for ourself.
So let's build it and run it.
All right.
So now let's place first of all, we need to enter the current year, for example, 2020.
All right.
And now the prompt waits for the age we should also put here at the age, let's say, as we've done
in our example, 30, let's press enter.
And now you were born in nineteen ninety nine.
Oh, so that's cool.
You can actually find the year that you were born.
Let's try another example, let's say.
All right.
Let's say so.
The year right now is 2020.
And for example, you are 57 years old.
Let's say 57.
Press enter and we can actually find out at the year that, for example, your father or grandfather
was who was born.
You were born in 1963.
Great.
All right.
So we've successfully completed our challenge.
And by the way, some of you may have also tried some other ways, some other solution by using an additional
variable to hold the calculated value of the birth year.
So you probably used something like this after you declare a variable.
Another variable called birth year.
Right.
And then before.
You printed out something on your screen, you just use something like death, birth year equals to
these to this guy, right?
He goes to these guy and then instead of writing any mathematical expression here, you just use the
birth year.
Right.
Something like that.
And that's totally OK.
You should work the same way.
We simply previously didn't use any additional variable as opposed to this example where we created
another temporary variable that helped us with this calculation.
But if any of you solved the sex or size with the additional variable like we've seen here, there is
nothing wrong with it.
It simply will work.
It will simply work the same way.
So this is it, guys, for this video.
I hope that everything runs on your side as well.
Right.
Relevant nodes for you from this challenge.
Different examples, different ways we solve the sex or size and preparing herself for the next challenge.
I'll see you there.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.