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 now that you tried to solve this exercise on your own, let's give it a shot together, shall we?
And first of all, we have to understand is let's just use the example, the previous example that we
have some data variable needs of a floating point, floating point type.
Right.
And for example, we had like twelve point seven with what we are requested to do is to extract these
information, these zero point seven after the decimal point.
So first of all, what I want us to do is just a quick reminder of how would you extract just the integer
type, right.
Just these 12 without a point seven.
And based on the result and based on the way that we are going to do it and the way that we've done
it previously, we are going to extract also these points zero.
So I hope you're ready to get yourself something nice to drink or maybe a pen and to write some notes.
And here we go.
So the first thing that we have to do is to create to declare a variable float data, write right after
words.
We are going to read these data, these value from the user.
So print f, print F, enter the data of floating point tied, for example.
OK, here we are going to read these data from the user by using this kind of function and we are going
to use the percentage F and to write it into data.
That's how we are going to solve it.
OK, so that's the first step.
Now what we have to do is if we want to print the integer itself, for example, the twelve, the full
part of these decimal number, what we have to do is simply just print half the decimal or the integer.
The integer better.
The integer path equals to percentage deep.
OK, instead at least percentage we if we would have used data.
OK, then let's see what will happen.
So build and run it.
Let's say we have twelve point seven and you will see some really strange number.
Right, one six one oh six.
Well what is that.
I'm trying just to get the percentage of data.
So there is a problem here.
Why didn't we get just 12?
And the reason is very simple, because data is stored as a float.
Right, as a floating memory.
And we are trying to read this information is an integer.
So here we have a problem.
OK, I'm not going to dive into all the details, into all the bytes and bits, let's say, of this
variable and how it's being read.
But simply know that if you store it as a float and you're trying to read it without any explicit casting
as an integer, then unexpected behavior may occur.
So what you have to do is, for example, to use explicit casting and to specify here and OK, so that's
an explicit casting.
And if we are going to build and run it, you will see that you get the integer parts 12, because you
know that INT is an explicit casting if you use it this way and it will simply take the integer part
of a given floating point number like we have here with data.
So I hope that's clear, right.
No questions about it.
If you still have any questions, feel free to ask them.
And all that remains right now is to pretend not the integer part, but rather the decimal part after
the decimal point.
So how it can be done?
It's actually it's very simple because you know that the initial data is twelve point seven, for example,
and we know how to get the integer part of the full part of it.
So if we will take the initial the actual data and subtracted with it, well, OK.
So if we use something like this so we know how to get the twelve and we are going to use twelve point
seven minus twelve and it will give us.
What do you think it will give us.
Zero point seven, which is exactly the floating point, the decimal path that we wanted to get.
So how should we do it?
So Preens have proven to have the decimal part, that same old part after the floating point.
After the floating point equal is two percentage F and here instead of the percent.
Jeff Placeholder, we are going to take the data, right, that's the initial data and use subtraction
of input data.
So we simply took twelve point seven minus 12.
Right, because we take just the integer path.
And basically what we got is the decimal part out of a hold of a given floating point variable, out
of a given floating point value.
So let's let's build and run it and see what happens.
So enter the data floating point type, let's say twelve point seven.
And there you go.
The decimal part is this one.
The integer part is that one freaking awesome.
And what now we have to do let's do another example.
We don't have to do anything right now.
Basically.
No, there was one thing that wanted to do is simply to kind of limit to the number of zeroes that we
can see.
Two point one, for example.
Okay.
Or point to let's make it like this.
So let's say five point seventy five.
So we expect the integer part to be five and the decimal bar to be zero point seventy five five and
zero point seventy five.
Awesome.
Guys, I think that's amazing.
Good job.
I guess that by now you start feeling like you're more confident with your knowledge and with applying
your skills in our C programming language.
So keep on practicing, keep on working hard.
And trust me, guys, there is no reason why if you have a lot of free time, I hope you do.
If not, try to find always some balance, try to find some free time to exercise and to solve more
exercises.
You're not wasting time for those of you who say, oh, that's very easy.
I know this one.
I know how to solve this one.
No, it's it's not the case.
It's the more you practice, the better you will be.
The more you learn, the smarter you probably will be.
So take your time, put in the hustle the hard work, and I guess you are about to succeed.
So my name is Vlad.
This is Alphatech.
Thank you so much for watching and I will see you next time.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.