27th August Batch Questions - Capgemini
1.
int i
set i =3
do
print i+3
i=i-1
while(i not equals 0)
end while
- 6 6 6
- 6 5 6
- 5 5 5
- 6 5 4
Ans- 4
2.
int i , j , k , n
set j =1, k=1
for(each i from 1 to 5)
print k
j=j+1
k=k+j
end for
- 1 3 6 10 15
- 1 2 3 4 5
- 2 4 6 8 10
- 1 1 2 3 5
Ans- 1
3. a=2
Integer fun (Integer a)
Integer x,y
Set y=3
for( each x from 0 to y-1)
a=a+y
End for
Return a
- 11
- 8
- 2
- 14
Ans- 1
4. a=2
Integer fun (Integer a) //a=2
if(a>0)
return a+ fun(a-1)
Else
return 0
End if
- 4
- 6
- 3
- 5
Ans- 3
5.
Integer arr[] = {10, 20, 30, 40, 5}
Integer a,s
Set s=0
Set a = arr[1] + arr[2]
Print a
- 25
- 5
- 50
- 40
Ans- 3
6.
Integer a,b,c
Set b = 40, a = 20, c = 20
if ( c > (c+a) )
b=0
Else
a = a + 2
c = a + 2
End if
Print a + b + c
- 25
- 5
- 50
- 40
Ans- 4
No comments:
Post a Comment