Que – 1. Predict output of following program
int main() { int i; int arr[5] = {1}; for (i = 0; i < 5; i++) printf("%d ", arr[i]); return 0; }
(A) 1 followed by four garbage values:
(B) 1 0 0 0 0
(C) 1 1 1 1 1
(D) 0 0 0 0 0
(B) 1 0 0 0 0
(C) 1 1 1 1 1
(D) 0 0 0 0 0
Que - 2. Predict output of the following program:
int main() { int a[][] = {{1,2},{3,4}}; int i, j; for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) printf("%d ", a[i][j]); return 0; }
(A) 1 2 3 4
(B) Compiler Error in line ” int a[][] = {{1,2},{3,4}};”
(C) 4 garbage values
(D) 4 3 2 1
(B) Compiler Error in line ” int a[][] = {{1,2},{3,4}};”
(C) 4 garbage values
(D) 4 3 2 1
Que - 3. Consider the following declaration of a ‘two-dimensional array in C:
char a[100][100];
Assuming that the main memory is byte-addressable and that the array is stored starting from memory address 0, the address of a[40][50] is: (GATE CS 2002)
(A) 4040
(B) 4050
(C) 5040
(C) 5050
(A) 4040
(B) 4050
(C) 5040
(C) 5050
Que - 4. For a C program accessing X[i][j][k], the following intermediate code is generated by a compiler. Assume that the size of an integer is 32 bits and the size of a character is 8 bits. (GATE-CS-2014)
t0 = i * 1024 t1= j * 32 t2 = k * 4 t3 =t1 + t0 t4 = t3 + t2 t5 = X[t4]
Which one of the following statement about the source code of C program is correct?
(A) X is declared as “int X[32][32][8]”
(B) X is declared as “int X[4][1024][32]”
(C) X is declared as “char X[4][32][8]”
(D) X is declared as “char X[32][16][2]”
(A) X is declared as “int X[32][32][8]”
(B) X is declared as “int X[4][1024][32]”
(C) X is declared as “char X[4][32][8]”
(D) X is declared as “char X[32][16][2]”
int *A [10], B[10][10];
Of the following expressions
I. A[2] II. A[2][3] III. B[1] IV. B[2][3]
which will not give compile-time errors if used as left hand sides of assignment statements in a C program (GATE CS 2003)?
(A) I, II, and IV only
(B) II, III, and IV only
(C) II and IV only
(D) IV only
(A) I, II, and IV only
(B) II, III, and IV only
(C) II and IV only
(D) IV only
0 Comments:
Post a Comment