Hey, guys, what's up?
So today we are going to solve a very simple and interesting problem.
So the problem statement is given a Farenheit value, we have to convert it into it, corresponding
saltiest value.
OK.
So the families Celsius equals five by nine.
Fahrenheit minus 32.
So this is the formula for converting a given Fahrenheit.
Will you do it Celsius value?
OK.
So user will give us the value of Fahrenheit.
And I will print its corresponding Celsius value.
OK.
So let's write Colford.
So let's nghiem this vitalize.
Fahrenheit to Celsius, not CBP.
Hash include your stream using namespace SDD and Main.
Done.
Zero.
OK.
So what I have to do.
OK, so what I have to do, first of all, let's create a variable and Farenheit and let us take the
value of Farenheit and Bird from the user.
Now we will calculate Celsius, which is equal to.
Five by nine and two Fahrenheit minus 32.
And after calculating Celsius value, we just have to print it out.
OK, so this is all that we have to do.
We are taking input and then we are calculating the Celsius value with the help of this formula.
And then we are printing the soldiers value.
So let's blend in.
So I think for fair nightclothes hindered my output.
Her T7.
Oh, it's coming out to be zero.
So let's see where this coming out to be zero.
OK, so.
I give Hundert as input.
So a hundred minus 32 is 68 and five by nine and 268 is in articles to zero.
Then why this coming out to zero?
So in the last class, I told you that integer upon integer is an integer visored.
So because this division operator.
Is an inbuilt function.
It is inward.
OK?
So it is defined in such a way that if you divide integer by another integer, the output will always
be an integer.
OK.
So it is defined in such a manner.
And here, focus on this part.
So five by nine is actually zero point five five five five five five.
But I told you that it will give me integer, so I output will be zero.
OK, so five by nine is it goes to zero and zero.
Multiply it by anything as it goes to zero.
OK.
So I hope you understood the problem.
Now how we can resolve it.
So first of all, this is wrong.
Let's come out.
So there are many ways to correct this problem.
So the first raise in sales years equals first.
What do we do?
We will multiply.
And then we will divide.
OK.
So first multiply.
Then divide.
So five.
And do Fahrenheit minus two.
And now we will do divide.
Divide, weigh nine.
OK, so let's Ballenden.
So let's give hundred as input, and today seven is my answer, correct answer.
Okay, so there is one more interesting.
So there is one more way with the help we get, with the help of which we can solve this problem.
To what we will do in the last class, I also told you that in the last class, I also told you that
flawed, divided by integer is an integer, sorry, flawed and similarly integer divided by a flawed.
It's also flawed.
So this division operator is defined in such a manner.
So we can use it how what we will do.
We will write five point zero divided by nine and then we will multiply it with Fahrenheit minus 32.
OK.
So what will happen?
This part, which is flawed upon integer, will give me a floating value and flawed and to endanger
will be flawed.
OK.
So my output will not be zero and output will be a correct.
Output will be correct.
OK.
So we just have to do minor changes.
We will simply write and Celsius equals five point zero divided by nine and two Fahrenheit minus 32.
What you can also do is instead of writing this, you can also write five divided by nine point zero
or you can also write five point zero divided by nine point zero.
So the these three are the same.
You can write any of them.
Okay, so but we have to do one more thing.
So when I'm writing in Celsius equals five point zero, divided by nine into Fahrenheit, minus 32.
So this value is a floating value and floating into each year and flowed into integer will be a floating
value.
So the Right-Hand side is a floating value and left hand side is an integer value.
Is indeed strange.
So what do we have to do?
We have to typecast it.
So for typecasting, we have to do explicit typecasting.
So we'll just.
Right.
And before this expression.
OK.
So why there's a need of typecasting here?
Because the right hand side is a floating value and the left hand side is an integer.
So we have to typecast floated a type into NBG editor type.
OK, so let's make some changes.
So I have come into this part because this is correct.
Let's see one more so in Celsius.
So we have to typecast and why we need to typecast.
Because right hand side is floating value and Left-Hand Side is a integer value.
So 5.0.
Divided by nine.
And then we were multiplied with Fahrenheit minus 32.
OK.
So for typecasting, we have to add black kids.
Now, this is correct.
So let's.
Ballenden.
So 400 miles, but would be 37, which is hundred percent correct.
OK.
So what what will happen if I add Brian Brend?
Two out.
Five by nine, White will print, it will be my output.
So it is actually zero point five.
But I told you integer one integer will give me integer.
So output will be zero.
Now, tell me, what will Mount Board if I do see out nine by five?
So it is when pointed, but my output will be in danger, in danger.
But it is not getting round of output will not be to round off, is not there.
We are just it will the revision operator will just give me the endangered part.
So that's why.
When is my output.
Similarly, if I had I'd see out four by three.
So it is one point three three three.
So our goal will be one.
Okay, so division operator is a little bit interesting.
So just focus.
So just try to concentrate and just remember, fuel will start in Dajarra one and data will be integer
floatable and data will be flawed and indeed hereupon flawed will be flawed and so on.
Okay.
Now what will happen if I try and print C out nine point zero by five.
So in this case my output will be one point eight.
OK.
Because Florida, born in danger, is a floating riluzole, so let's try and paint this.
And this.
So let's come into doubt.
See out.
Nine by five.
OK, so first of all, I want to give Farenheit value, so my output is one, OK?
So nine by five is coming out to be one.
So let's come in and also let's come into doubt also.
And now let's sprint CE out.
Nine point zero sorry, nine point zero by five.
Now, in this case, Wildwood will be one point eight.
OK, so when branded because Florida wedding deejay is a floating you, now let's print one more thing.
See out followed by three.
And see out five by nine.
So you can see here, nine by five is one, nine point zero by five is one point eight, four by three
is actually 123.
Burton Deja opponent Deja is in danger.
So when it's getting Brender and my last one is zero.
OK.
OK guys.
So this is it for this video.
Thanks for watching.