0% found this document useful (0 votes)
14 views10 pages

Accenture Psedocode - 3

Uploaded by

nilesh.k0901
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views10 pages

Accenture Psedocode - 3

Uploaded by

nilesh.k0901
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

1 Correct Ans : C Added By : fc15074 October 4, 2023, 11:57 am Edit

What will be the output of the following pseudocode for p = 3 and q = 4?

int fun1(int p, int q)

if(q EQUALS 0)

return 0

if(q mod 2 EQUALS 0)

return fun1(p + p, q/2) .

return fun1(p + p, q/2) + p

End function fun1()

A. None of the options

B. 7

C. 12

D. 8

2 Correct Ans : D Added By : fc15074 October 4, 2023, 11:58 am Edit


What will be the output of the following pseudocode?

Integer x, y, Z, a

Set x=2,y=1,z=5

a = (x AND y) OR (z + 1)

Print a

A. 5

B. 3

C. 2

D. 1
3 Correct Ans : B Added By : fc15074 October 4, 2023, 11:58 am Edit
What will be the output of the following pseudocode for a = 2, b = 3?

doSomething(Integer a, Integer b)

if(b EQUALS 1)

return 0

else

return a+ doSomething(a, b-1)

End function doSomething()

A. 3

B. 4

C. 2

D. 1

4 Correct Ans : D Added By : fc15074 October 4, 2023, 11:58 am Edit


What will be the output of the following pseudocode?

Integer a, n, sum, q, r

Set a=123, n=0, sum=0

Set q=a

while (q mod 10 NOT EQUALS 0)

n=n+1

q=q/10

End while

Print n
while (a greater than 0)

r=a mod 10

sum =sum + r

a =a/power(10, n- 1)

End while

Print sum

A. 3 2

B. 6 4

C. 6 5

D. 3 4

5 Correct Ans : D Added By : fc15074 October 4, 2023, 11:59 am Edit


What will be the output for the following pseudocode?

Integer a=5,b=8,c

if(a>8 OR b < 7)

c=a+b

elseif(a + b > 9)

c=a-b

else

a=a+5

c=c-2

end if

a=a+b
Print a and c

b=b-5

A. None of the mentioned

B. 5 -3

C. 5 1

D. 13 -3

6 Correct Ans : C Added By : fc15074 October 5, 2023, 9:35 am Edit


What will be the output of the following pseudocode for a = 9, b = 7?
Integer funn(Integer a, Integer b)
Integer c
Set c = 2
b = b mod c
a = a mod c
return a + b
End function funn()

a. 17
b. 5
c. 2
d. -5

7 Correct Ans : C Added By : fc15074 October 5, 2023, 9:37 am Edit


What will be the output of the following pseudocode?
Integer a, b, c
Set a = 8, b = 6,c = 4
If(a > b)
a=b
Else
b=a
End If
If(c> b)
c=b
Else
b=c
End If
Print a + b + c

a. 13

b. 17

c. 14

d. 23

8 Correct Ans : A Added By : fc15074 October 5, 2023, 9:37 am Edit


What will be the output of the following pseudocode?
Integer a, b, c
Set a = 1, b = 1, c = 7
a=a+b
if(a + b)
if(b + (c ^ a))
a=2
b=a
End if
End if
Print a + b + c

If(x) gets executed if the value inside ifo, i.e., x is not zero]
a. 11

b. 6

c. 12

d. 22

9 Correct Ans : C Added By : fc15074 October 5, 2023, 9:36 am Edit


What will be the output of the following pseudocode?
Integer a, b, c
Set a = 8, b = 6,c = 4
If(a > b)
a=b
Else
b=a
End If
If(c> b)
c=b
Else
b=c
End If
Print a + b + c

a. 13

b. 17

c. 14

d. 23

10 Correct Ans : D Added By : fc15074 October 5, 2023, 9:39 am Edit


What will be the output of the following pseudocode?
Integer p, q, r, s
Set p=1, q = 1for (each r from 0 to 2 )
for (each s from -4 to -2 )
p = p + 2if(p > r)
Continue
End if
p = 1if(p > s)
Jump out of the loop
End if
End for
End for
Print p + q

13

24

35

20
11 Correct Ans : A Added By : fc15074 October 5, 2023, 9:39 am Edit
What will be the output of the following pseudocode for input a = 30, b = 60, C = 90?
Integer a, b, c, sum
Read a, b, c
Set sum = a + b + c
if ((sum EQUALS 180) and (a NOT EQUALS 0) and (b NOT EQUALS 0) and (c NOT EQUALS
0))
Print " Success"
Otherwise
Print "Fail"
End if

a. Success

b. Error in the logic of the pseudocode

c. Fail

d. None of the mentioned options

12 Correct Ans : B Added By : fc15074 October 5, 2023, 9:44 am Edit


What will be the output of the following pseudocode for a = 4, b = 8?
Integer funn(Integer a, Integer b)

if(a > b)

End if

if(b > a)

End if

b=b^a

a=a^b

return a + b

End function funn()

A. 35

B. 20
C. 14

D. 25

13 Correct Ans : D Added By : fc15074 October 5, 2023, 9:42 am Edit


What will be the value of the following pseudocode?
Integer x, y

for(each x from 1 to 11)

x=x+2

end for

Print x

A.11

B.10

C.12

D.13

14 Correct Ans : C Added By : fc15074 October 5, 2023, 9:42 am Edit


What will be the value of the following pseudocode?
Integer j, m

Set m = 1, j = 1

Integer a[3] = {0, 1, 0}

a[0] = a[0] + a[1]

a[1] = a[1] + a[2]

a[2] = a[2] + a[0]

if(a[0])

a[j] = 5
End if

m = m + a[j]

Print m

A.3

B.2

C.6

D.4

15 Correct Ans : B Added By : fc15074 October 5, 2023, 9:43 am Edit


What will be the value of the following pseudocode for k=150?
fun(integer k)

if(k>155)

return

end if

print k

fun(k+2)

print k

End of function fun()

A. 150 152 154

B. 150 152 154 154 152 150

C. 150

D. None of the mentioned

16 Correct Ans : D Added By : fc15074 October 4, 2023, 12:02 pm Edit


What will be the output of the following pseudocode?

Initialize Integer x, y, z
Set y = 1, x = 2
z=x^y
Print z
a. 1

b. 2

c. 4

d. 3

17 Correct Ans : A Added By : fc15074 October 4, 2023, 12:03 pm Edit


Which of the following series will be printed by the given pseudocode?

Integer a, b, c
Set b = 4, c = 5
for(each a from 2 to 4)
print c
b=b-1
c=c+b
end for
a. 5 8 10

b. 1 3 6

c. 8 9 10

d. 3 6 9

You might also like