Accenture Pseudo Code Questions and Answers
Accenture Pseudo Code 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
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
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#
a) 15625
b) 625
c) 3125
d) 525
a) 64
b) 97
c) A
d) Error
#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
a) 35795
b) 3 5 7 9 11
c) 3 5 9 15 20
d) Error
#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);
}
#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
#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
#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
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) It accepts a string
b) It reverses the string
c) It prints the string in same order
d) None of these
#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
a) PrepInsta
b) Prepinsta Prime
c) Prime
d) Error
#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
#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>
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
#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
#include<stdio.h>
int main()
{
char c= 'Z';
printf(“%d”,c);
}
a) 90
b) 122
c) ‘Z’
d) Z
#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
#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
#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
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
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
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
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
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
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
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
a) 654
b) 642
c) 321
d) 123
ch = ‘b’;
while(ch >= ‘a’ && ch <= ‘z’)
ch++;
}
a) Compilation error
b) 25
c) 26
d) 1
return sum;
}
a) 2n+8
b) 2n+4
c) 2n+2
d) 2n
a) 56
b) 72
c) 88
d) 65
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
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
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
a) 7
b) 8
c) -7
d) 19
a) 21
b) 17
c) 20
d) 8
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#
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
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
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?
a) 44
b) 0
c) 1
d) 12
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
fun(integer k)
if(k>155)
return
end if
print k
fun(k+2)
print k
End of function fun()
a) 7 13 13 11 11
b) 3 5 1 -5 -9
c) -3 -5 -1 5 9
d) None
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
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
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
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
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
a) 40
b) 30
c) 44
d) 0
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?
a) -9
b) 5
c) 6
d) 21
a) 35
b) 20
c) 14
d) 25
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