5 8 2024-Gate
5 8 2024-Gate
statement is?
db = foo (da);
}
double foo (double a) { return a;
}
The above code compiled without any error or warning. If Line 1 is
deleted, the above code will show:
A. no compile warning or error
B. some compiler-warnings not leading to unintended results
C. some compiler-warnings due to type-mismatch eventually
leading to unintended results
D. compiler errors
Consider line number 3 of the following C-program.
int main ( ) { /* 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:
A. No compilation error
B. Only a lexical error
C. Only syntactic errors
D. Both lexical and syntactic errors
Consider these two functions and two statements S1 and S2 about them.
int work1(int *a, int i, int j)
{
int x = a[i+2]; a[j] = x+1; return a[i+2] - 3;
}
int work2(int *a, int i, int j)
{
int t1 = i+2; int t2 = a[t1]; a[j] = t2+1; return t2–3;
}
S1: The transformation from work1 to work2 is valid, i.e., for any program state and
input arguments, work2 will compute the same output and have the same effect
on program state as work1
S2: All the transformations applied to work1 to get work2 will always improve the
performance (i.e reduce CPU time) of work2 compared to work1
foo(513, 2)?
(a) 9 (b) 8 (c) 5 (d) 2
The following C declaration
struct node
{
int i; float j;
};
struct node *s[10] ; define s to be
#include<stdio.h>
void f(int *p, int *q)
{
p = q;
*p = 2;
}
int i = 0, j = 1; int main()
{
f(&i, &j);
printf("%d %d \n", i, j); getchar();
return 0;
}
A. ABCD EFGH
B. ABCD
C. HGFE DCBA
D. DCBA