SAPLAB Previous Years Solved Sample Placement Papers
-
If int is 2 bytes wide, what will be the output of the program?
#include
void fun(char**);
int main()
{
char *argv[] = {"ab", "cd", "ef", "gh"};
fun(argv);
return 0;
}
void fun(char **p)
{
char *t;
t = (p += sizeof(int))[-1];
printf("%sn", t);
}A. ab
B. cd Answer: Option B
C. ef
D. gh
-
What will be the output of the program if the array begins at 65486 and each integer occupies 2 bytes?
int main()
{
int arr[] = {12, 14, 15, 23, 45};
printf("%u, %un", arr+1, &arr+1);
return 0;
}A. 12, 65490
B. 14, 65492
C. 65488, 65496 Answer: Option C
D. 64490, 65498
-
Recursive functions are executed in a:
A. last in first out order Answer: Option A
B. first in first out order
C. are maintained in a stack
D. none of the above
-
What will be the output of the program?
#include
int main()
{
int i = 3, j = 4, k, l;
k = addmult(i, j);
l = addmult(i, j);
printf("%d %dn", k, l);
return 0;
}
int addmult(int ii, int jj);
{
int kk, ll;
kk = ii + jj;
ll = ii * jj;
return (kk, ll);
}A. Function addmult() return 7 and 12
B. No output
C. Error: Compile error Answer: Option C
D. None of the above
-
Point out the error, if any, in the while loop:
main()
{
int i = 0;
while()
{
printf("%d", i++);
if (i > 10)
break;
}
}A. The condition in the while loop is a must Answer: Option A
B. The while loop must be replaced by a for loop
C. All of the above
D. None
-
What will be the output of the program?
#include
void fun(int);
int main()
{
int a = 3;
fun(a);
return 0;
}
void fun(int n)
{
if (n > 0)
{
fun(-n);
printf("%d,", n);
fun(-n);
}
}A. 0, 2, 1, 0
B. 1, 1, 2, 0
C. 0, 1, 0, 2
D. 0, 1, 2, 0 Answer: Option D
-
What will be the output of the following C program?
int main()
{
int fun()
{
_AX = 1990;
}
}A. Garbage value
B. 0 (Zero)
C. 1990 Answer: Option C
D. No output
-
What will be the output of the program?
for (printf("1"); !printf("0"); printf("2")) printf("Sachin");
return 0;
}A. 10Sachin2
B. 10Sachin
C. 10Sachin210Sachin2
D. 10 Answer: Option D