Input array elements 1,2,3,4,5,6,7,8
Initialize n as number of elements
Initialize sum equals 0
i=n-1
Function SUM(array,i,sum)
If(i<0)
Write sum
if((ar[i]%2==1)
sum+=(ar[i])
SUM(array,i-1,sum)
ENDIF
ENDFUNCTION
A.36
B.20
C.16
D.10
C
.input a=8,b=16
int fun(int a,int b)
{
int n=0
if(b<1)
return n
else
return fun(a+b+2,b-2)
}
A.33
B.88
C.0
D.128
C
Integer a,b,c,d
Set a=14,b=15,c=16
If(a>6)
b=c-a
if(a>c)
d=b+c
else
d=b-c
else
d=a+b+c-3
print d
A.29
B.-14
C.31
D.18
B
Find output of given pseudocode for n=5?
Function Sum(int num) (<> not equals to)
If(num<>0)
Return num+num*sum(num-1)
Else
Return num
Endif
Endfunction
A.325
B.188
C.64
D.320
A
Integer n,beg,end
Set beg=5,end=7,sum=0
If(beg>end)
Print sum+1
Else
For(n=end;n>=beg;n=n-1)
Sum=sum+n
N=n-1
End for loop
Print n
A.6
B.4
C.9
D.3
D
Assume that objects of the type short,float and long occupy 2 bytes,4 bytes and 8
bytes respectively.The memory required for variable t,ignoring alignments
considerations,is:
struct{
short s[5]
union{
float y;
long z;
}u;
}t;
A.22
B.24
C.18
D.10
C
bin1=1010 bin2=1000
READ input bin1,input bin2
INITIALIZE i equals 0,rem equals 0
INITIALIZE array ar of size 20
While(bin1!=0 or bin2!=0)
sum[i++]=(bin1%10+bin2%10+rem)%2
rem=(bin1%10+bin2%10+rem)/2
bin1=bin1/10
bin2=bin2/10
EndWhile
If(rem!=0)
sum[i++]=rem
–i
Endif
While(i>=0)
Print sum[i–]
EndWhile
A.10011
B.10010
C.0010
D.1000
B
num=12
FUNCTION factor(input num)
int i,j,primeno;
for(i=2;i<=num;i++)
if(num%i==0)
SET primeno as TRUE
Endif
Endfor
for(j=2;j<=i/2;j++)
if(i%j==0)
SET primeno as FALSE
Break
Endif
Endfor
If primeno is TRUE
WRITE i
A.2 3 4 6 12
B. 4 6 12
C. 2 3
D. 12
E. 1 2 3
C
Read array a[5]={5,1,15,20,25}
Initialize i, j, m
i=++a[1]
j=a[1]++
m=a[i++]
Write i, j, m
A.2, 1, 15
B.1, 2, 5
C.3, 2, 15
D.2, 3, 20
C
Integer i=0,j
While(i<2)
{
j=0;
while(j<=3*i)
{
print j
print blank space
j=j+3
}
Print end-of-line
I=i+1
}
A.0
0 3
B.0 3
0 3 6
C.0
0 3 6
0 3 6 9
D.0 3 6
0 3 6 9
0 3 6 9 12
A