Computer Sciences > Gate 2017 Set-2 > C code
Consider the C program fragment below which is meant to divide x by y using repeated subtractions. The variable x, y, q and r are all unsigned int.
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)?
while(r >= y)
{
r = r - y;
q = q + 1;
}
{
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)?
Correct : C code
Similar Questions
Consider the following program in C language:
#include <stdio.h>
main()
{
int i;
int *pi = &i;
scanf("%d",...
Consider the following two C code segments. Y and X are one and two dimensional arrays of size n and n × n respectively, where 2 ≤ n ≤ 10. Assume that in both c...
Consider the following C program segment.
#include<stdio.h>
int main( )
{
char s1[7] = "1234", *p;
p = s1 + 2;
...
Total Unique Visitors
Loading......