Loops


Q11.

Consider line number 3 of the following C-program. int min ( ) { /* Line 1 */ int I, N; /* Line 2 */ fro (I =0, I < N, I++); /* Line 3 */ } Identify the compiler's response about this line while creating the object-module:
GateOverflow

Q12.

Consider the following C code. Assume that unsigned long int type length is 64 bits. unsigned long int fun(unsigned long int n){ unsigned long int i, j = 0, sum = 0; for (i = n; i > 1; i = i/2) j++; for ( ; j > 1; j = j/2) sum++; return(sum); } The value returned when we call fun with the input 2^{40} is
GateOverflow

Q13.

Consider the following C-function in which a[n] and b[m] are two sorted integer arrays and c[n+m] be another integer array. void xyz (int a[],int b[],int c[]){ int i, j, k; i=j=k=0; while((i < n))&&(j < m) if (a[i] < b[j]c[k++]=a[i++]; else c[k++]=b[j++]; } Which of the following condition(s) hold(s) after the termination of the while loop ? I. j\ltm, k=n+j-1, and a [n-1]\ltb[j] if i=n II. i\ltn, k=m+i-1, and b[m-1]\leqa[i] if j=m
GateOverflow

Q14.

What does the following algorithm approximate? (Assume m \gt 1, e \gt 0). x = m; y = 1; while (x - y > e) { x = (x + y)/2; y = m/x; } print(x);
GateOverflow