[go: up one dir, main page]

50% found this document useful (4 votes)
10K views31 pages

Accenture Pseudo Code Questions and Answers

Uploaded by

s.roshan582003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
50% found this document useful (4 votes)
10K views31 pages

Accenture Pseudo Code Questions and Answers

Uploaded by

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

Accenture Pseudocode Questions and Answers

Part I
Accenture Pseudocode Questions #1
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()
[Note- mod finds the remainder after the division of one number by another. For example, the
expression "5 mod 2 leaves a quotient of 2 and a remainder of 1.]
a) 17
b) 5
c) 2
d) -5
Accenture Pseudocode Questions #2
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
Accenture Pseudocode Questions #3
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

[Note- ^ is the bitwise exclusive OR operator that compares each bit of its first operand to the
corresponding bit of other bit is 1, the corresponding result bit is set to 1. Otherwise, the
corresponding result bit is set to 0.

If(x) gets executed if the value inside ifo, i.e., x is not zero]
a) 11
b) 6
c) 12
d) 22
Accenture Pseudocode Questions #4
What will be the output of the following Pseudocode?
Integer p, q, r, s
Set p=1, q = 1
for (each r from 0 to 2 )
for (each s from -4 to -2 )
p=p+2
if(p > r)
Continue
End if
p=1
if(p > s)
Jump out of the loop
End if
End for
End for
Print p + q
[Note- Continue: When a continue statement is encountered inside a loop of statements inside the
body of the loop for the current iteration.]
a) 13
b) 24
c) 35
d) 20

Accenture Pseudocode Questions #5


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) None of the mentioned options
c) Error in the logic of the Pseudocode
d) Fail

Accenture Pseudocode Questions #6


What will be the output of the following Pseudocode for a =1, b =2?

Integer funn(Integer a, Integer b )


if(a<3 && b<4)
return funn( a +1, b + 1)
Else
Return a + b
End if
End function funn()
[Note: &&: Logical AND operator - the logical AND operator (&&) returns the Boolean value
true (true () if both
a) 8
b) 19
c) -7
d) 7

Accenture Pseudocode Questions #7


What will be the output of the following Pseudocode for a = 2, b = 6?
Integer funn(Integer a, Integer b
If(a > 0)
If(b > 0)
Return a + b + funn(a + 1, 0) + funn(a + 2, 0) + funn(a + 3, 0)
End If
End If
Return a + b
End Function funn()
a) 21
b) 17
c) 37
d) 20

Accenture Pseudocode Questions #8


What will be the output of the following Pseudocode for a = 4, b = 6?
Integer funn(Integer a, Integer b)
If(a > 2)
If(b > 2)
Return a + b + funn(a + 1, b - 5)
End If
End If
Return a - b
End function funn()
a) 17
b) 14
c) 22
d) 12
Accenture Pseudocode Questions #9
What will be the output of the following Pseudocode?
Integer p, q, r
Set p= 3, q =1, r = 2
If(p+ (2&2&2) && q + (3&3&3) && r + (2^2^2))
p=p-2
q=p
Else
p=r
q=q^2
End If
Print p+ q+ r
[Note- &&: Logical AND - The logical AND operator (88) returns the Boolean value true(or 1)
if both operands are true and return false (or &: bitwise AND - The bitwise AND operator (8)
compares each bit of the first operand to the corresponding bit of the second operand. If the
corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0.
^is the bitwise exclusive OR operator that compares each bit of its first operand to the
corresponding bit of its second operand. If one bit is 1, the corresponding result bit is set to 1.
Otherwise, the corresponding result bit is set to 0.

If(x) gets executed if the value inside if(), i.e., x is not zero]
a) 8
b) 4
c) 16
d) -8
Accenture Pseudocode Questions #10
What will be the output of the following Pseudocode?
Integer p, q, r
Set p = 0, q = 4, r = 3
If(p || r)
If(p && r)
p = p &r
End If
p=p^r
End If
Print p + q + r
[Note- &&: Logical AND - The logical AND operator (&&) returns the Boolean value true(or 1)
if both op &: bitwise AND - The bitwise AND operator (&) compares each bit of the first
operand to the correspon corresponding result bit is set to 1. Otherwise, the corresponding result
bit is set to 0.
a) 10
b) 20
c) 12
d) 7
Accenture Pseudocode Questions #11
What will be the output of the following Pseudocode for a = 4 and b = 9?
Integer funn(Integer a, Integer b)
If(a < b)
Return 1 + funn(a, b - 2)
End If
If(a^b > a&b)
Return a ^ b
Else
Return a & b
End If
Return 1
End function funn()
[Note- &: bitwise AND - The bitwise AND operator (&) compares each bit of the first operand
to the corresponding bit of the corresponding result bit is set to 1. Otherwise, the corresponding
result bit is set to 0.

^ is the bitwise exclusive OR operator that compares each bit of its first operand to the
corresponding bit of its second operator is 1, the corresponding result bit is set to 1. Otherwise,
the corresponding result bit is set to 0.)
a) -8
b) 24
c) 14
d) 10

Accenture Pseudocode Questions #12


What will be the output of the following Pseudocode for a = 4, b = 6?
Integer funn(Integer a, Integer b)
If(a > 1)
Return a * funn (b - 6, a - 4)
Else
Return 1
End If
Return a + b
End function funn()
a) 0
b) 17
c) 4
d) 7

Accenture Pseudocode Questions #13


What will be the output of the following Pseudocode?
Integer p, q, r
Set q = 30, p = 10, r = 20
If (r > (r + p))
q=1
Else
p=p-2
r=r-2
End If
If (r > (q + p) || 1)
q = (0 ^ 5)
Else
p=p+2
r=p+2
End If
Print p + q + r
[Note- ^ is the bitwise exclusive OR operator that compares each bit of its first operand to the
corresponding bit of its second op other bit is 1, the corresponding result bit is set to 1.
Otherwise, the corresponding result bit is set to 0]
a) 20
b) 40
c) 30
d) 31

Accenture Pseudocode Questions #14


What will be the output of the following Pseudocode?
Integer count
For (each count from 0 to 9)
Print "#"
If (count > 6)
CONTINUE
Print count
End For
[Note: When a continue statement is encountered inside a loop, control jumps to the beginning of
the statements inside the body of the loop for the current iteration]
Ops:

a) 0#1#2#
b) #0#1#2#3#4#5 #6# # #
c) 0##1#2#3#4#5# #7#8#9#10
d) 0 #0#1#2#3#4#5#

Accenture Pseudocode Questions #15


What will be the output of the following Pseudocode?
Integer a = 50, b = 23, c
c=a+b
c = c MOD b
b=b+c
a=a-b
Print a, b, c
[Note: MOD finds the remainder after the division of one number by another. For example, the 2
leaves a quotient of 2 and a remainder of 1)
a) 23 27 4
b) 23 17 3
c) 77 27 4
d) 69 19 4

Accenture Pseudocode Questions #16


What will be the output of the following pseudo-code:
Integer m
Set m = 0
Integer p[5] = {1, 1, 0, 1, 7}
If (p[0] && P[4])
m = p[1]
End If
If (p[2] && p[3])
m = p[2]
End If
Print m
[Note-&&: Logical AND - The logical AND operator (88) returns the Boolean value true(or 1) if
both operands are true and 1f(x) gets executed if the value inside it, Le., x is not zero
a) 18
b) 1
c) -5
d) 4
Accenture Pseudocode Questions #17
What will be the output of the following Pseudocode?
Integer j, m
Set m = -1
Integer a[5] = { 3, 0, 1, 0, 2 }
For(each j from m+1 to m+5)
If(a[j] & j)
a[j] = a[j] & j
End If
End For
m=a[0] + a[4] - a[1]
Print m
[Note: &: bitwise AND - The bitwise AND operator (&) compares each bit of the first operand
to the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0]
a) 15
b) 4
c) 5
d) 8
Accenture Pseudocode Questions #18
What will be the output of the following Pseudocode?
Integer j, m
Set m=0
Integer a[4] = {10, 11, 3, 2}
For(each j from m to m+3)
If( j > 0)
a[j] = a[j-1] + 2
End If
End For
m = a[0] + a[2] + a[1]
Print m
a) 52
b) 41
c) 36
d) 29

Accenture Pseudocode Questions and Answers


Part II
Accenture Pseudocode Questions #19
What will be the output of the following Pseudocode?
For input a = 5 & b = 5.
function (input a, input b)
If (a < b)
return function (b, a)
elseif (b != 0)
return (a * function (a, b - 1))
else
return 0

a) 15625
b) 625
c) 3125
d) 525

Accenture Pseudocode Questions #20


What will be the output of the following Pseudocode
initialize char c
set c= a
print "%d",a

a) 64
b) 97
c) A
d) Error

Accenture Pseudocode Questions #21


What will be the output of the following code ?

#include<stdio.h>
int main ()
{
char c,a,b;
c='f';
a='s';
b='x';
int sum= c+a+b;
printf ("%d", sum);
}
a) 324
b) 315
c) 320
d) 337

Accenture Pseudocode Questions #22


What will be the output of the following Pseudocode for arr[]= 1,2,3,4,5
initialize i,n
intialize an array of size n
accept the values for the array
for i= 0 to n
arr[i] = arr[i]+arr[i+1]
end for
print the array elements

a) 35795
b) 3 5 7 9 11
c) 3 5 9 15 20
d) Error

Accenture Pseudocode Questions #23


What will be the output of the following Pseudocode ?

#include<stdio.h>
int fun(int x, int y);
int main()
{
int i,n;
i=5;
n=7;
int f = fun(5,7);
printf("%d", f);
}

int fun(int x, int y)


{
if(x<=0)
return y;
else
return(fun(x-1,y-1));
}
a) 0
b) 1
c) 2
d) 3

Accenture Pseudocode Questions #24

What will be the output of the following code

#include <stdio.h>
#include <stdlib.h>
#define LIMIT 10 /*size of integers array*/
int main(){
unsigned long long int i,j;
int *primes;
int z = 1;
primes = malloc(sizeof(int)*LIMIT);
for (i=2;i<LIMIT;i++)
primes[i]=1;
for (i=2;i<LIMIT;i++)
if (primes[i])
for (j=i;i*j<LIMIT;j++)
primes[i*j]=0;
for (i=2;i<LIMIT;i++)
if (primes[i])
printf("%dth prime = %dn\n",z++,i);
return 0;

a) None

b) 1th prime – 2n
2th prime – 3n
3th prime – 5n

c) 1th prime – 2n
2th prime – 3n
3th prime – 5n
4th prime – 7n

d) 1th prime – 2n
2th prime – 3n
3th prime – 5n
4th prime – 7n
5th prime – 9n
6th prime – 11n

Accenture Pseudocode Questions #25


What will be the output of the following code snippet?

#include <stdio.h>
#include <stdlib.h>int main(){
int m = 2, c=1;
int n,a,b, limit=10;
while(c < limit)
{
for (int n = 1; n < m; ++n)
{
a = m * m - n * n;
b = 2 * m * n;
c = m * m + n * n;
if (c > limit)
break;
printf("%d %d %d\n", a, b, c);
}
m++;
}
}

a) 1 5 7
b) 2 5 7
7 9 10

c) 1 2 3
456
789

d) 3 4 5
8 6 10

Accenture Pseudocode Questions #26

What will be the output of the following Code ?

#include<stdio.h>
int main( )
{
int n=5, k, f1, f2, f;
if ( n < 2 )
return n;
else
{
f1 = f2 = 1;
for(k=2;k<n;k++)
{
f = f1 + f2;
f2 = f1;
f1 = f;
}
printf("%d",f) ;
}
}
a) 8
b) 13
c) 5
d) 7

Accenture Pseudocode Questions #27


What purporse does the following code serves

int main()
{
int array[] = {5, 3, 1, 9, 8, 2, 4, 7};
int size = sizeof(array)/sizeof(array[0]);
int i, j, min_idx,temp;
for (i = 0; i < size-1; i++)
{
min_idx = i;
for (j = i+1; j < size; j++)
{
if (array[j] < array[min_idx])
min_idx = j;
}
temp = array[min_idx];
array[min_idx] = array[i];
array[i] = temp; }
}

a) Find some specific element in an array


b) Sort the elements in an array
c) Find the smallest element in an array
d) None of these

Accenture Pseudocode Questions #28

What operation does the following Pseudocode performs

Declare an array of string type variable called word


Declare a loopcounter
Store a string in the array word
for loopcounter = (length of the word) – 1 to 0
loopcounter = loopcounter – 1
print arrayword[loopcounter]
endfor
Algorithm end

a) It accepts a string
b) It reverses the string
c) It prints the string in same order
d) None of these

Accenture Pseudocode Questions #29


What will be the output of the following pseudocode?

#include<stdio.h>
int func(int a)
{
return a--;
}
int main()
{
int a= func(5);
printf("%d",a++);
return 0;
}
a) 4
b) 5
c) 6
d) 7

Accenture Pseudocode Questions #30

What will be the output of the following pseudocode?


#include<stdio.h>
int main()
{
float m=3.0;
switch((int)m)
{
case 1:
printf("Prepinsta");
break;
case 2:
printf("Prime");
break;
case 3:
printf("Prepinsta Prime");
break;
}
return 0;
}

a) PrepInsta
b) Prepinsta Prime
c) Prime
d) Error

Accenture Pseudocode Questions #31


What will be the output of the following Pseudocode?

#include<stdio.h>
int main()
{
int val=5;
do{
val++;
++val;
}while(val++>7);
printf("%d",val);
return 0;
}
a) 11
b) 10
c) 8
d) 7

Accenture Pseudocode Questions #32


What will be the output of the following pseudocode?

#include<stdio.h>
int main()
{
int m=0;
if(m==0)
{
m=((5,(m=3)),m=1);
printf("%d",m);
}
else
printf("Test");
return 0;
}
a) Test
b) 1
c) 3
d) 5
Accenture Pseudocode Questions #33
What will be the output of the following Pseudocode?

#include<stdio.h>

void fun1(char *s1, char *s2) {


char *tmp;
tmp = s1;
s1 = s2;
s2 = tmp;
}

void fun2(char **s1, char **s2) {


char *tmp;
tmp = *s1;
*s1 = *s2;
*s2 = tmp;
}

int main () {
char *str1 = "Prepinsta", *str2 = "Prime";
fun1(str1, str2); printf("%s %s ", str1, str2);
fun2(&str1, &str2); printf("%s %s ", str1, str2);
return 0;
}
a) Prepinsta Prime Prime Prepinsta
b) Prepinsta
c) Prepinsta Prime
d) Error

Accenture Pseudocode Questions #34

What will be the output of the following Pseudocode ?

#include<stdio.h>
void main()
{
int i=0;
while(+(+i--)!=0)
i=i+5;
printf("%d",i);
}
a) 4
b) 5
c) -1
d) -2

Accenture Pseudocode Questions #35


What will be the output of the following Pseudocode ?

#include<stdio.h>
int main()
{
char c= 'Z';
printf(“%d”,c);
}
a) 90
b) 122
c) ‘Z’
d) Z

Accenture Pseudocode Questions #36


What will be the output of the following Pseudocode ?

#include<stdio.h>
int func(int n)
{
int i=0;
while(n%10!=0)
{
n=n+3;
i++;
}
n=n-i;
return n;
}
void main()
{
printf("%d",func(35));
}
a) 50
b) 55
c) 53
d) 45

Accenture Pseudocode Questions #37


What will be the output of the following Pseudocode ?

#include<stdio.h>
int func(int no)
{
static int count=0;
count=count+no;
return count;
}
void main()
{
int i,j;
for(i=0;i<=5;i++)
j=func(i);
printf("%d",j);
}

a) 18
b) 15
c) 20
d) 25

Accenture Pseudocode Questions #38


What will be the output of the following Pseudocode ?

#include<stdio.h>
void main()
{
int a=5,b=2,c=1;
if(b>a && a>c && c>b)
b=a+1;
else
a=b+1;
printf("%d",a+b+c);
}
a) 6
b) 11
c) 19
d) 7
Accenture Pseudocode Questions and Answers
Part III

Accenture Pseudocode Questions #39


What will be the value of s, if n=127?

Read n
i=0,s=0
Function Sample(int n)
while(n>0)
r=n%10
p=8^i
s=s+p*r
i++
n=n/10
End While
Return s;
End Function

a) 27
b) 87
c) 187
d) 120

Accenture Pseudocode Questions #40


What will be the value of s if N=20?

Read N
Function sample(N)
s=0
f=1
i=1
while i <= N:
f=f*i
s = s +(i / f)
i+=1
End while
return(s);
End Function

a) 3.789456
b) Infinite loop
c) 2
d) 80

Accenture Pseudocode Questions #41


What will be the output if limit = 6?

Read limit
n1 = 0, n2= 1, n3=1, count = 1;
while count <= limit
count=count+1
print n3
n3 = n1 + n2
n1 = n2
n2 = n3
End While

a) 112358
b) 12358
c) 123581321
d) 12358132

Accenture Pseudocode Questions #42


What will be the value of even_counter if number = 2630?

Read number
Function divisible(number)
even_counter = 0, num_remainder = number;
while (num_remainder)
digit = num_remainder % 10;
if digit != 0 AND number % digit == 0
even_counter= even_counter+1
End If
num_remainder= num_remainder / 10;
End While
return even_counter;
a) 3
b) 4
c) 2
d) 1

Accenture Pseudocode Questions #43


What will be the value of t if a = 56 , b = 876?

Read a,b
Function mul(a, b)
t=0
while (b != 0)
t=t+a
b=b-1
End While
return t;
End Function
a) 49056
b) 490563
c) 490561
d) None of these

Accenture Pseudocode Questions #44


Which line has error?

Read size
Read a[1],a[2],…a[size]
i=0
While(i<size)
j=i+1
While(j<size)
If a[i] < a[j] then
t= a[i];
a[i] = a[j];
a[j] = t;
End If
j=j+1
End While
i=i+1
End While
i=0
While (i<size)
print a[i]
i=i+1
End While

a) Line 4
b) Line 6
c) Line 7
d) No error

Accenture Pseudocode Questions #45


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) Fail
c) Compilation Error
d) None of these

Accenture Pseudocode Questions #46


What will be the output of the following pseudo-code?
integer i
set i=3
do
print i+3
i=i-1
while( i < 0)
end while

a) 654
b) 642
c) 321
d) 123

Accenture Pseudocode Questions #47

How many times the following loop will be executed?


main()
{

ch = ‘b’;
while(ch >= ‘a’ && ch <= ‘z’)
ch++;
}
a) Compilation error
b) 25
c) 26
d) 1

Accenture Pseudocode Questions #48


Consider the following piece of code. What will be the space required for this code?

int sum (int A[], int n)


{
int sum = 0, i;
for (i = 0; i < n; i++)
sum = sum + A[i];

return sum;
}
a) 2n+8
b) 2n+4
c) 2n+2
d) 2n

Accenture Pseudocode Questions #49


What will be the output of the following Pseudocode?

For input a = 8 & b = 9.


function (input a, input b)
If (a < b)
return function (b, a)
elseif (b != 0)
return (a + function (a, b - 1))
else
return 0

a) 56
b) 72
c) 88
d) 65

Accenture Pseudocode Questions #50


What will be the output of the following Pseudocode?

Input m = 9, n = 6;
m=m+1;
n=n-1;
m=m+n
if (m > n)
print m
else
print n

a) 6
b) 5
c) 10
d) 15

Accenture Pseudocode Questions #51


What will be the output of the following pseudo-code?

Input f = 6, g = 9 and set sum = 0


Integer n

if (g > f)
for (n = f; n < g; n = n + 1)
sum = sum + n
End for loop
print sum
else
print error message

a) 21
b) 15
c) 9
d) 6

Accenture Pseudocode Questions #52


What would be the output of the following pseudocode?

Integer i, j, k
Set k = 8
for(each i from 1 to 1)
for(each j from the value of i to 1)
print k+1
end for
end for

a) 9
b) 89
c) 4
d) 3

Accenture Pseudocode Questions #53


What will be the output of the following pseudocode for a =1, b =2?

Integer funn(Integer a, Integer b )


if(a<3 && b<4)
return funn( a +1, b + 1)
Else
Return a + b
End if
End function funn()

a) 7
b) 8
c) -7
d) 19

Accenture Pseudocode Questions #54


What will be the output of the following pseudocode for a = 2, b = 6?

Integer funn(Integer a, Integer b)


if(a > 0)
if(b > 0)
return a + b + funn(a + 1, 0) + funn(a + 2, 0) + funn(a + 3, 0)
End if
End if
return a + b
End function funn()

a) 21
b) 17
c) 20
d) 8

Accenture Pseudocode Questions #55


What will be the output of the following pseudocode?

Integer count
for (each count from 0 to 9)
print "#"
if (count > 6)
CONTINUE
print count
End for

a) 0#1#2#3#4#5#6##
b) #0#1#2#3#4#5#6##
c) 0#1#2#3#4#5#6#7#8#9#
d) 0#1#2#3#4#5#

Accenture Pseudocode Questions and Answers


Part IV
Accenture Pseudocode Questions #56
Integer x, y, z
Set x = -2, y = 3, z = 1
if(x + (2 & 2) && y + (3 & 3) && z + (2 ^ 2))
x=x-2
y=x
Else
x=z
y=y^2
End if
Print x+ y+ z
a) 2
b) 11
c) 3
d) 0

Accenture Pseudocode Questions #57


Print the output of the following pseudocode for x = 9, y = 7.

Integer funn(Integer x, Integer y)


Integer z
Set z = 2
y = y mod z
x = x mod z
return x + y
End function funn()
a) 2
b) 3
c) 17
d) 5

Accenture Pseudocode Questions #58


Integer x, y, z
Set x = 8, y = 6, z = 4
if(x > y)
x=y
Else
y=x
End if
if(z > y)
z=y
Else
y=z
End if
Print x + y + z
a) 13
b) 17
c) 14
d) 23

Accenture Pseudocode Questions #59


Integer a, b, c, d
Set a = 1, b = 1
for (each c from 1 to 2 )
for (each d from -2 to 0 )
a=a+2
if(a > c)
Continue
End if
a=1
if(a > d)
Jump out of the loop
End if
End for
End for
Print a + b
a) 8
b) 22
c) 30
d) 14

Accenture Pseudocode Questions #60


Calculate the output of the following pseudocode for input p = 3, q = 8, r = 1.

Integer p, q, r, sum
Read p, q, r
Set sum = p + q + r
if ((p NOT EQUALS 0) and (sum EQUALS 11) and (q EQUALS 4) and (r NOT EQUALS 0))
Print " Success"
Otherwise
Print "Fail"
End if
a) Success
b) Fail
c) Error
d) None of the above

Accenture Pseudocode Questions #61


Calculate the output of the following Pseudocode.

Integer w, x, y, z
Set w = 1, x = 1
for (each y from 11 to 20 )
for (each z from -3 to 0 )
w=w+5
if(w > y)
Continue
End if
w=1
if(w > z)
Jump out of the loop
End if
End for
End for
Print w + x
a) 8
b) 12
c) 3
d) 2

Accenture Pseudocode Questions #62


Integer x, y, z
Set x = 10, y = 16, z = 3
if(x > y)
x=y
Else
y=x
End if
if(z > y)
z=y
Else
y=z
End if
Print x + y + z
a) 13
b) 12
c) 16
d) 20

Accenture Pseudocode Questions #63


Predict the output of the following pseudocode for a = 11, b = 12.

Integer solve(Integer a, Integer b )


if(a < 3 && b < 4)
return solve(a + 1, b + 1)
Else
Return a + b
End if
End function solve()
a) 13
b) 12
c) 22
d) 23

Accenture Pseudocode Questions #64


Predict the output of the following pseudocode for x = 4, y = 9.

Integer solve(Integer x, Integer y)


if(y > 0)
if(x > 0)
return x + y + solve(0, y + 1) + solve(0, y + 2) + solve(x + 3, 0)
End if
End if
return x + y
End function solve()
a) 20
b) 15
c) 41
d) 30

Accenture Pseudocode Questions #65


Predict the output of the following pseudocode for n = 5, m = 6.

Integer solve(Integer n, Integer m )


if(n > 4 && m < 7)
return solve(n +1, m + 1)
Else
Return n + m
End if
End function solve()

a) 15
b) 21
c) 13
d) 10
Accenture Pseudocode Questions and Answers
Part V
Accenture Pseudocode Questions #66
What will be the value of the following pseudocode?

Integer value, n, num


Set value = 1, n = 45
num = num >> 1
num = num + value
Print num

a) 44
b) 0
c) 1
d) 12

Accenture Pseudocode Questions #67

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

Accenture Pseudocode Questions #68


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

Accenture Pseudocode Questions #69


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

Accenture Pseudocode Questions #70


What will be the output of the following pseudocode?

Integer a[5], b[5], c[5], k, l


Set a[5] = {5, 9, 7, 3, 1}
Set b[5] = {2, 4, 6, 8, 10}
for(each k from 0 to 4)
c[k] = a[k] - b[k]
end for
for(each 1 from 0 to 4)
Print c[1]
end for

a) 7 13 13 11 11
b) 3 5 1 -5 -9
c) -3 -5 -1 5 9
d) None

Accenture Pseudocode Questions #71


How many times “A” will be printed in the following pseudocode?

Integer a, b, c
for(a = 0 to 4)
for(b = 0 to 2)
if(a is greater than b)
Print “A”
End for
End for
End if
a) 8
b) 7
c) 9
d) 10

Accenture Pseudocode Questions #72


What will be the output of the following pseudocode?

Integer p, q, r
Set q = 13
for(each p from 1 to 4)
r = q mod p
p=p+5
q=p+r
end for r = q / 5
Print q, r

a) 64
b) 13
c) 72
d) 61

Accenture Pseudocode Questions #73


What will be the output of the following pseudocode?

Integer x
Set x = 259 if(x EQUALS 0)
Print “0”
otherwise if(x MOD 9 EQUALS 0)
Print “9”
otherwise
Print x MOD 9
end if

a) 8
b) 16
c) 7
d) None

Accenture Pseudocode Questions #74


What will be the output of the following pseudocode?

Integer a, b
Set a = 12, b = 25
a = (a + b) MOD 2
b=b=a
a = a + b - 13
Print a, b

a) -11 1
b) -12 00
c) 11 22
d) 37 24

Accenture Pseudocode Questions #75


What will be the output of the following pseudocode?

Integer a, b, c
Set a = 4, b = 4, c = 4
if (a & (b ^ b) & c)
a = a >> 1
End if
Print a + b + c

a) 16

b) 24
c) 8
d) 12

Accenture Pseudocode Questions #76


What will be the output of the following pseudocode for a = 10, b = 11?

Integer funn(Integer a, Integer b)


if(0)
return a - b - funn(-7, -1)
End if
a=a+a+a+a
return a
End function funn()

a) 40
b) 30
c) 44
d) 0

Accenture Pseudocode Questions #77


What will be the output of the following pseudocode for a = 5, b = 1?

Integer funn(Integer a, Integer b)


if((b + a || a - b) && ((b > a) && 1))
a = a+b+b-2
return 3-a
Else
return a-b+1
End if
return a+b
End function fun()

a) 0
b) 5
c) 16
d) 11
Accenture Pseudocode Questions #78
What will be the output of the following pseudocode for a = 5, b = 1?

Integer funn(Integer a, Integer b)


if((b mod a && a mod b) || (a ^ b > a))
a=a^b
Else
return a-b
End if
return a+b

End function funn()

a) -9
b) 5
c) 6
d) 21

Accenture Pseudocode Questions #79


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

Accenture Pseudocode Questions #80


What will be the output of the following pseudocode?

Integer x
Set x = 2
if(x is EQUAL TO 1)
if(x IS EQUAL TO 0)
Print “A”
else
Print “B”
end if
else
Print “C”
end if
a) BC
b) C
c) A
d) B

You might also like