Texas Previous Years Solved Sample Placement Papers
-
If a 5-stage pipeline is flushed and then we have to execute 5 and 12 instructions respectively, then the number of cycles will be:
A. 5 and 12
B. 6 and 13
C. 9 and 16 Answer: Option C
D. None
- Solution: A 5-stage pipeline requires initial stages to be flushed before execution, so for 5 and 12 instructions, 4 cycles are added initially, resulting in 9 and 16 cycles respectively.
-
K-map:
AB ------ C 1 X 0 0 1 X 0 X
Solve it:
A. A.B
B. ~A
C. ~B
D. A+B Answer: Option A
- Solution: From the K-map, the minimal expression is A.B.
-
CHAR A[10][15] AND INT B[10][15] are defined. What's the address of A[3][4] and B[3][4] if the address of A is 0x1000 and B is 0x2000?
A. 0x1030 and 0x20C3
B. 0x1031 and 0x20C4 Answer: Option B
- Solution: Calculation is based on the sizes of CHAR (1 byte) and INT (4 bytes) along with the indices.
-
int f(int *a) { int b = 5; a = &b; } main() { int i; printf("\n %d", i); f(&i); printf("\n %d", i); }
What's the output?
A. 10, 5
B. 10, 10
C. 5, 5
D. None Answer: Option D
- Solution: Variable `i` is uninitialized, and assigning `a` in `f()` doesn't affect the original `i`.
-
main() { int i; fork(); fork(); fork(); printf("----"); }
How many times is the `printf` executed?
A. 3
B. 6
C. 5
D. 8 Answer: Option D
- Solution: Each `fork()` creates a new process, resulting in 2^3 = 8 processes executing the `printf`.
-
void f(int i) { int j; for (j = 0; j < 16; j++) { if (i & (0x8000 >> j)) printf("1"); else printf("0"); } }
What's the purpose of the program?
A. Its output is the hex representation of i
B. BCD
C. Binary Answer: Option C
D. Decimal
- Solution: The program prints the binary representation of the integer `i`.
-
#define f(a,b) a+b #define g(a,b) a*b main() { int m; m = 2 * f(3, g(4, 5)); printf("\n m is %d", m); }
What's the value of m?
A. 70
B. 50
C. 26
D. 69 Answer: Option D
- Solution: Macro expansion results in `2 * (3 + (4 * 5)) = 69`.
-
main() { char a[10]; strcpy(a, "\0"); if (a == NULL) printf("\a is null"); else printf("\n a is not null"); }
What happens with it?
A. Compile-time error
B. Run-time error
C. a is null
D. a is not null Answer: Option D
- Solution: `a` is not a null pointer; it points to a valid memory location even if it's empty.
-
`char a[5] = "hello";`
A. In array, we can't do the operation
B. Size of a is too large
C. Size of a is too small Answer: Option C
D. Nothing wrong with it
- Solution: The size of the array is insufficient to hold the string along with the null terminator.
-
Local variables can be stored by the compiler:
A. In register or heap
B. In register or stack Answer: Option B
C. In stack or heap
D. Global memory
- Solution: Local variables are stored in registers or the stack, depending on their usage.
-
Average and worst time complexity in a sorted binary tree is:
A. O(log n) and O(n)
B. O(n) and O(n) Answer: Option A
- Solution: For balanced trees, average complexity is O(log n), while for unbalanced trees, it can degrade to O(n).
-
Convert 40.xxxx into binary:
A. 101000.xxxx Answer: Option A
-
Global variable conflicts due to multiple file occurrence are resolved during:
A. Compile-time
B. Run-time
C. Link-time Answer: Option C
D. Load-time
-
Two programs are given for factorial, one with recursion and one without. Which program won't run for very big numbers due to stack overflow?
A. i only Answer: Option A
B. ii only
C. i & ii both
D. None