Loading...

Loading, please wait...

The Code Concepts
Learning Portal
Prep plan My packages

Practice over 1000+ GATE-level questions from this topic!

Designed to match the latest GATE pattern with topic-wise precision, difficulty tagging, and detailed solutions.

Q#1 Control Flow Statements MCQ +1 mark -0.33 marks

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

        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) ?

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

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

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

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

Sign in to see the solution

Log in to view the explanation, track your attempts, and keep your progress.

Sign in to Unlock
Browse Practice Questions by Chapters / Topics in Browse Practice Questions by Chapters / Topics in GATE Computer Science
Total Questions

Attempted

% Attempted

Correct

% Correct

Topic Questions Attempted Correct
C Programming and Data Structures 142 0 0
Algorithms 113 0 0
DBMS 13 0 0
Operating Systems (OS) 0 0 0
Computer Networks 22 0 0
CDS 10 0 0
C Programming & Data Structure 22 0 0
20 0 0 0