C-Programming-data-structure || 2017 SET 2|| MCQ || 2-mark || Module 1: C Programming

Last Updated :
Discuss
Comments

Consider the C program fragment below which is meant to divide x and y using repeated subtractions. The variables x, y, q and r are all unsigned int.

         

C
while (r >= y)  {
r = r - y;
q = q + 1;
}


Which of the following conditions on the variables x, y, q and r before the execution of the fragment will ensure that the loop terminates in a state satisfying the condition x == (y*q + r)? 2017 SET 2|| MCQ || 2-mark


(q == r) && (r == 0)


 (x > 0) && (r == x) && (y > 0)


(q == 0) && (r == x) && (y > 0)

 (q == 0) && (y > 0)

Share your thoughts in the comments
Article Tags :