Accenture OLT-5
Accenture OLT-5
OLT-5
=========================================================
Ans: a
#include <stdio.h>
int main()
{
int i = 0, j = 0;
l1: while (i < 2)
{
i++;
while (j < 3)
{
printf("loop\n");
goto l1;
}
}
return 0;
}
a) loop loop
b) compilation error
c) loop loop loop loop
d) infinite loop
Answer A
Print( i , j )
end loop
end loop
A)1 1
B)1 1 1 2 1 3
c)1 1 infinite times
D)compilation error
Ans:A
Q6. Consider the code given below, which runs insertion sort:
Answer: b
return 0;
}
A) Compiler error
B) FLOWER FRUITS
C) FLOWER YELLOW
D) FLOWER YELLOW 1 FRUITS
Ans: C
Q.9 What does the above program print foo (1234, 0)?
void foo(Integer n, Integer sum)
Integer k = 0, j = 0
IF (n EQUALS 0)
return
k = n MOD 10
sum = sum + k
Print (k)
foo (n/10, sum)
end foo
A) 4, 3, 2, 1
B) 1, 2, 3, 4
C) 1, 3 , 6, 10
D) 0, 1, 2, 3
Ans: A
#include<stdio.h>
void test(int * , int *);
main()
{
int a = 5 , b = 6;
test(&a,&b);
printf("%d %d",a,b);
}
void test(int *p, int *q)
{
*p = *p ^ *q;
*q = *p ^ *q;
*p = *p ^ *q;
}
A. 30 5
B. 6 5
C. 5 6
D. None of the above
Ans:B
int main()
{
printf("%d", fun(4, 3));
getchar();
return 0;
}
a)12
b)11
c)10
d)13
Ans:A
int main()
{
int a = 4;
fun(a);
getchar();
return 0;
}
a)1 0 2 3 0 0 1
b)0 1 2 0 3 0 1
c)1 0 2 3 0 0 3
d)1 1 2 3 0 0 1
Ans:b
Q. 14 Consider an array of length 5, arr[5] = {9,7,4,2,1}. What are the steps of insertions done
while running insertion sort on the array?
a) 7 9 4 2 1 4 7 9 2 1 2 4 7 9 1 1 2 4 7 9
b) 9 7 4 1 2 9 7 1 2 4 9 1 2 4 7 1 2 4 7 9
c) 7 4 2 1 9 4 2 1 9 7 2 1 9 7 4 1 9 7 4 2
d) 7 9 4 2 1 2 4 7 9 1 4 7 9 2 1 1 2 4 7 9
Answer: a
Q15. Select the most appropriate output for the following C code:
int main()
{ int i = 90;
int j = (i++, --i, i++);
printf("%d %d", i, j);
}
a. 91 91
b. 90 90
c. 91 90
d. Compiler Dependent
Answer: c
Q16. Select the most appropriate output for the following C code:
main()
{ int x=-28,d,e;
d=!x;
e=~x;
printf("%d %d",d,e);
}
a. 0 29
b. 0 -27
c. 1 28
d. 1 0
Answer:B
Q17. Select the most appropriate output for the following C code:
int main()
{ int a1 = 51;
int b1 = 0;
int c2 = a1 || --b1;
int d3 = a1-- && --b1;
printf("a1 = %d, b1 = %d, c2 = %d, d3 = %d", a1, b1, c2, d3);
}
a. a1 = 50, b1 = -1, c2 = 1, d3 = 1
b. a1 = 50, b1 = -2, c2 = 1, d3 = 1
c. a1 = 51, b1 = -1, c2 = 1, d3 = 1
d. None
Answer: a
Q18. Assuming, integer is 2 byte, What will be the output of this code for fun(2)?
fun(int n):
Integer X=-2
Print(X<<n)
A. ffff
B. 0
C. fff8
D. Error
Ans: C