Function fun(){
Input num=40
Return num--
}
Function main()
{
for(fun() ; fun() ; fun()) {
print fun();
}
Question 1
Answer
Question 1
Predict the output of the above code.
Answer
38 35 32 29 26 23 20 17 14 11 8 5 2
Function main()
char *s[] = { "knowledge","is","power"} char **p
p = s print
++*pprint
*p++print
++*p
Question 2
Answer
Question 2
A. nowledge nowledge s
B. knowledge knowledge is
C. knowledge nowledge s
D. is power
Answer
A. nowledge nowledge s
for X=5 to 1
for Y=1 to X
print Y
Question 3
Answer
Question 3
How many times the loop will execute?
A. 12
B. 13
C. 14
D. 15
Answer
D. 15
Function foo(int* a, int* b)
sum = *a + *b
*b = *a
RETURN *a = sum - *b
Function main()
int i = 0, j = 1, k = 2, l; l = i++ OR
foo(&j, &k) print(i, j, k, l)
Question 4
Answer
Question 4
A. 1 2 1 1
B. 1 1 2 1
C. 1 2 2 1
D. 1 2 2 2
Answer
A. 1 2 1 1
Read
count=5 Set x to
0; While(x <
count)
Set even to even +
2x = x + 1
write even
Question 5
Answer
Question 5
A. 2 4 6 8 10
B. 0 2 4 6 8
C. 2 4 6 8
D. 0 2 4 6
Answer
B. 0 2 4 6 8
Also Checkout: TCS NQT Sample Question Paper
begin
q := 0 // q is going to contain floor(x/y)
r := x // r is going to contain x % y
// Repeatedly subtract y from x.
while r >= y do
begin
r := r – y
q := q + 1
end
end
Question 6
Answer
Question 6
The post condition that needs to be satisfied after the program terminates is:
A. {r = qx + y A r < y}
B. {x = qy + r A r < y}
C. {y = qx + r A 0 < r < y}
D. { q + 1 0}
Answer
B. {x = qy + r A r < y}
READ m = 10
Initialize n & n1
n = m++
n1 = ++m
n--
--n1
n -= n1
Write n
Question 7
Answer
Question 7
A. 0
B. 1
C. -2
D. None of these.
Answer
C. -2
Function f(int* p, int m)
m = m - 5
*p = *p - m
return;
EndFunction
Function main()
Input i=10, j=5
f(&i, j)
print i+j
Question 8
Answer
Question 8
A. 5
B. 25
C. 15
D. 30
Answer
C. 15
Function main()
Input ch
Write”Enter value between 1 to 2:”
Read ch
switch(ch,ch+1)
Case 1:
50.
Function f(int* p, int m)
m = m - 5
*p = *p - m
return;
EndFunction
Function main()
Input i=10, j=5
f(&i, j)
print i+j
Write “1”
Case 2:
Write “2”
break
Default:
Write “3”
Question 9
Answer
Question 9
what will be the output when entered 1?
A. 1 2
B. 2
C. 3
D. 2 3
Answer
B. 2
input num=134
Function fun1(int num)
Static int a=0
If(num>0)
a=a+1
fun1(num/10)
else
return a
Question 10
Answer
Question 10
A. 8
B. 3
C. 2
D. 431
Answer
B. 3
n=2
int fun(int n)
if(n equals 5)
return n
else
return 2*fun(n+1)
Question 11
Answer
Question 11
A. 20
B. 16
C. 5
D. 40
Answer
D. 40
IF LOC=-1 do ITEM NOT
FOUNDDo_(DATA,N,ITEM,LOC)
Initialize counter set LOC=0,LOW=0,HI=N-1
[Search for item]Repeat while LOW<=HI
MID=(LOW+HI)/2
IF ITEM=DATA[MID]
do2.3LOC=MID
Return LOC
IF ITEM<DATA[MID]
HI=MID-1
ELSE
LOW=MID+1
Question 12
Answer
Question 12
A. The elements in an array should be in the sorted form
B. The array should contain more than one element
C. The elements in an array should be in unsorted form.
D. No pre-condition is required for the algorithm to follow.
Answer
B. 3
Also Checkout