Oracle Previous Years Solved Sample Placement Papers
-
What is the output of the program:
void main() { int j[10] = {9, 7, 5, 3, 1, 2, 4, 6, 9}; int i = 1; clrscr(); for(; i < 9; i++) printf("%d ", --j[i++]); getch(); }
A. 6,2,1,5
B. 6,2,1,5,7
C. Error Message
D. core dump Answer: Option A
- Solution: The loop iterates and decrements the values in the array based on the given logic, producing the sequence 6, 2, 1, 5.
-
What is the output of the program:
void main() { int i, j, k, n = 5; clrscr(); for(i = 5; i > 0; i--) { j = 1 < i; k = n & j; k == 0 ? printf("0") : printf("1"); } getch(); }
A. 00011
B. 11110 Answer: Option B
C. 11001
D. 11100
- Solution: The program outputs binary based on the bitwise AND operation and the loop conditions.
-
Which of the following storage class(es) became the global variable for the entire program:
A. Extern Answer: Option A
B. Static
C. Auto
D. Register
- Solution: The `extern` keyword makes a variable global and accessible across different files.
-
What is the output of the program, if integer occupies 2 bytes memory:
union { int a; char b; char c[10]; } u1; void main() { int l = sizeof(u1); printf("%d", l); getch(); }
A. 13
B. 10 Answer: Option B
C. 16
D. None of the above
- Solution: The union size is determined by the largest member, which is the char array of size 10.
-
What is the output of the program:
void main() { fork(); printf(" Hello World"); getch(); }
A. Hello World
B. Hello World Hello World Answer: Option B
C. Error Message
D. None of these
- Solution: The `fork()` system call creates a new process, resulting in the message being printed twice.
-
What is the output of the program:
void main() { struct a { int i; char *st1; }; typedef struct a ST; ST *str1; str1 = (ST*)malloc(100); str1->i = 100; strcpy(str1->st1, "Welcome to Oracle"); printf(" %d%s\n", str1->i, str1->st1); getch(); }
A. core dump
B. will not compile
C. 100, Welcome to Oracle Answer: Option C
D. None of these
- Solution: Memory is allocated, and the values are printed as expected.
-
What is the output of the program:
void main() { int i, j, k; i = 2; j = 4; k = i++ > j & 2; printf("%d\n", k); if(++k && ++i < --j || i++) { j = ++k; } printf(" %d %d %d", i, -j--, k); getch(); }
A. 4, -3, 2
B. 5, -3, 2
C. 4, -2, 2
D. 5, -2, 2 Answer: Option D
- Solution: The operations and precedence rules determine the final output.
-
Which of the following is not true in case of Command line arguments:
A. The argc parameter is used to hold the number of arguments in the command line and is an integer
B. The argv parameter is a pointer to an array of character pointers and each one points to command line arguments
C. The argv[1] always points to program name Answer: Option C
D. None of the above
- Solution: The program name is always `argv[0]`, not `argv[1]`.
-
What is the output of the program:
#include
#include #define sqr(a) a*a void main() { int a = 10, b = 1, c; c = sqr(10+1); printf("Sqr Root of (10+1) is %d", c); getch(); } A. 121
B. 21 Answer: Option B
C. 13
D. Syntax Error
- Solution: Macro substitution leads to incorrect evaluation of the expression.
-
What is the output of the program:
#include
#include void main() { int i, j = 20; clrscr(); for(i = 1; i < 3; i++) { printf("%d,", i); continue; printf("%d", j); break; } getch(); } A. 1,20
B. 1,20,1,20
C. 1,2 Answer: Option C
D. 1,2,20,20
- Solution: The `continue` statement skips the rest of the loop body, so only `i` is printed.