+ 2

Help about C language

If the result of an integer division, where both the numerator and the denominator are integers, is a fraction, the fractional part is____?

1st Oct 2021, 4:54 PM
Shoug Souliman
Shoug Souliman - avatar
20 Answers
+ 3
"the fractional part is..." ... obtained by using the modulus operator, % and doing floating point divide of the denominator. Or in decimal, by performing the division in floating point and using the frac() library function.
1st Oct 2021, 5:46 PM
Brian
Brian - avatar
+ 2
truncated? There could be many different answers...
1st Oct 2021, 4:57 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 2
It depends on data types you are storing the division result
1st Oct 2021, 5:01 PM
Mohd Aadil
Mohd Aadil - avatar
+ 2
Shoug Souliman , so correct answer is "rounded down to the nearest integer"
1st Oct 2021, 5:10 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 2
Eashan Morajkar , yes. So? It's incomplete answer to his question.
1st Oct 2021, 5:11 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 2
During an integer and an integer division the fractional part is removed
1st Oct 2021, 5:17 PM
Eashan Morajkar
Eashan Morajkar - avatar
+ 2
Eashan Morajkar yup, this will also be a correct answer...
1st Oct 2021, 5:18 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 2
Brian The fractional part are the numbers at the right of the decimal point e.g 2.31 Fractional part = 31 Its the part gotten by subtracting the integer part of number by the number
1st Oct 2021, 5:50 PM
Eashan Morajkar
Eashan Morajkar - avatar
+ 2
To get only the fractional part in C: num-((int) num)
1st Oct 2021, 5:52 PM
Eashan Morajkar
Eashan Morajkar - avatar
+ 2
akshay atugade , please post your question in a new thread rather than posting it here...
2nd Oct 2021, 3:52 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 2
The division of both integer will result in integer division.if you want the result in fraction Define the denominator as fraction value. Eg: 5/5=1 5/5.0=1 0
2nd Oct 2021, 5:58 PM
Gopinath
Gopinath - avatar
+ 2
Rishi , did he delete his answer or you just posted this in the wrong thread?
3rd Oct 2021, 12:07 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 2
Aleksei Radchenkov lol he deleted his answer His answer: I will help you I got the answer, just follow my account *his account link* But the person I tagged is right, he did that I'm sure😂
3rd Oct 2021, 3:00 PM
Rishi
Rishi - avatar
+ 2
Shoug Souliman its answer depends upon the data type in which you are storing the fractional value. If you store in integer data type then it give always the integer value, and same will be in the case of float but in float case you will get the the integer value with append zero only(will not give the exact fractional Result).
28th Oct 2021, 8:18 AM
Neeraj Kumar
Neeraj Kumar - avatar
+ 1
Shoug Souliman, if you put the division result inside int or if you print it, the result will be rounded down to the nearest integer.
1st Oct 2021, 5:03 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 1
Eashan Morajkar , this is just a single case... It doesn't mean any division will result in 0. For example if you divide 5/3 it will result in 1, so as I said it will be rounded down.
1st Oct 2021, 5:08 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 1
Even if you change division to int data type, the output will be 0, which means the fractional part is also 0
1st Oct 2021, 5:08 PM
Eashan Morajkar
Eashan Morajkar - avatar
+ 1
Aleksei Radchenkov But the fractional part is still 0
1st Oct 2021, 5:10 PM
Eashan Morajkar
Eashan Morajkar - avatar
+ 1
How to convert input string into the list... How to calculate each letter letter in string. eg. Hi hello So returns 7 letters
2nd Oct 2021, 3:41 PM
akshay atugade
+ 1
The fractional part is lost
27th Jan 2022, 5:08 AM
Kabiru Mahmud