closed by
315 views
0 votes
0 votes
closed with the note: Answered.
Let a, b be two positive integers, which of the following options correctly relates / and %?

(a) b= (a/b) * b + a%b                                                (b) b= (a%b) * b + a/b

(c) a= (a/b) * b + a%b                                                (d) a= (a%b) * b + a/b
closed by

1 Answer

Best answer
1 votes
1 votes
Let's take $a=20$ and $b=10$

$(a)$  $b= (\frac{a}{b})\times b + a\%b$

            $b= (\frac{20}{10})\times 10 + 20\%10$  
   
              $b= (2)\times 10 + 0$

                 $b=20$

   $(b)$  $b= (a\%b)\times b + \frac{a}{b}$

               $b= (20\%10)\times 10 + \frac{20}{10}$

              $b= (0)\times 10 + 2$

                $b=2$

   $(c)$  $a= (\frac{a}{b})\times b + a\%b$

                 $a= (\frac{20}{10})\times 10 + 20\%10$

                    $a=(2)\times 10+0$

                 $a=20$           

$(d)$  $a= (a\%b)\times b + \frac{a}{b}$

             $a= (20\%10)\times 10 + \frac{20}{10}$

              $a=(0)\times 10 +2$
 
               $a=2$
selected by

Related questions

0 votes
0 votes
2 answers
1
Sk Jamil Ahemad asked Feb 1, 2022
352 views
Please explain with some example that How Right to Left associativity takes place in case of Ternary operators?