You are on page 1of 200

Topic/Course

Topic/Course
Sub-Topic (Example: name of college)

Sub-title: name of college or company (for CSAC courses)


CoCubes - Accenture
Question 1
What will be the output of the following pseudocode?
Code/Pseudo Code
1 n=5
2 i = 0, s = 0
3 Function Sample ( int n )
4 while( n > 0 )
5 r = n % l0
6 p = 8 ^ i
7 s = s + p * r
8 i = i + 1
9 n = n / 10
10 End While
11 Return s
12 End Function
13
14
Question 1

A) 27
B) 187
C) 13
D) 120
Question 1

A) 27
B) 187
C) 13
D) 120
Question 2
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer n
2 for (n = 3; n != 0; n--)
3 Print n
4 n = n-1
5 end for
6
7
8
9
10
11
12
13
14
Question 2

A) 31
B) 321
C) 3
D) Infinite loop
Question 2

A) 31
B) 321
C) 3
D) Infinite loop
Question 3
What will be the output of the following pseudocode?
Code/Pseudo Code
1 For input a = 8 & b = 9.
2 Function(input a, input b)
3 If(a < b)
4 return function(b, a)
5 elseif(b != 0)
6 return (a + function(a,b-1))
7 else
8 return 0
9
10
11
12
13
14
Question 3

A) 56
B) 78
C) 72
D) 68
Question 3

A) 56
B) 78
C) 72
D) 68
Question 4
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer a = 10, b = 20
2 b = (a + b)-(a = b)
3 Print a
4 Print b
5
6
7
8
9
10
11
12
13
14
Question 4

A) 10 20
B) 20 10
C) 15 15
D) 1010 10100
Question 4

A) 10 20
B) 20 10
C) 15 15
D) 1010 10100
Question 5
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Input a[10]={1,2,3,4,5,6,7,8,9,10}
2 Print * a + 1 - * a + 3
3
4
5
6
7
8
9
10
11
12
13
14
Question 5

A) 44
B) 4
C) Error
D) 100
Question 5

A) 44
B) 4
C) Error
D) 100
Question 6
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer i=0
2 while( + (+i--)!= 0)
3 i- = i + 1;
4 end while
5 Print i
6
7
8
9
10
11
12
13
14
Question 6

A) 1
B) -1
C) 0
D) Error
Question 6

A) 1
B) -1
C) 0
D) Error
Question 7
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer a = 1, b = 0
2 b = ++a + ++a
3 Print a
4 Print b
5
6
7
8
9
10
11
12
13
14
Question 7

A) 11
B) 10
C) 22
D) Compiler Dependent
Question 7

A) 11
B) 10
C) 22
D) Compiler Dependent
Question 8
What will be the output of the following pseudocode?
Code/Pseudo Code
1 input n = 5
2 num = 1
3 while ( num <= n )
4 if ( num % 2 == 1)
5 print num
6 num = num + 1
7 End while
8
9
10
11
12
13
14
Question 8

A) 135
B) 13579
C) 9
D) No output
Question 8

A) 135
B) 13579
C) 9
D) No output
Question 9
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Input n = 5
2 num = 1
3 while ( num = 2 * n)
4 if( num % 2 == 1)
5 print num
6 num = num + 1
7 End while
8
9
10
11
12
13
14
Question 9

A) 135
B) 13579
C) 9
D) No output
Question 9

A) 135
B) 13579
C) 9
D) No output
Question 10
What will be the output of the following pseudocode?
Code/Pseudo Code
1 x = 4
2 y = ++x
3 z = x++
4 Print x
5 Print y
6 Print z
7
8
9
10
11
12
13
14
Question 10

A) 455
B) 655
C) 454
D) 656
Question 10

A) 455
B) 655
C) 454
D) 656
Question 11
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer i = 0
2 while ( ++i < 5 )
3 print i
4 end while
5
6
7
8
9
10
11
12
13
14
Question 11

A) 1234
B) 01234
C) 4
D) Error
Question 11

A) 1234
B) 01234
C) 4
D) Error
Question 12
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer i = 0
2 while ( i++ < 5 )
3 print i
4 end while
5
6
7
8
9
10
11
12
13
14
Question 12

A) 12345
B) 1234
C) 01234
D) Infinite loop
Question 12

A) 12345
B) 1234
C) 01234
D) Infinite loop
Question 13
What is the intention of the following pseudocode?
Code/Pseudo Code
1 input base = 2, exponent = 3
2 power = 1
3 for num = 1 to exponent
4 power = power * base
5 end for
6 print power
7
8
9
10
11
12
13
14
Question 13

A) Factorial of a number
B) Prime Number
C) Power of a number
D) None of these
Question 13

A) Factorial of a number
B) Prime Number
C) Power of a number
D) None of these
Question 14
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Input f = 6,g = 9 and set sum = 0
2 Integer n
3 if(g > f)
4 for(n = f ; n < g ; n = n + 1)
5 sum = sum + n
6 End for loop
7 else
8 print error message
9 print sum
10
11
12
13
14
Question 14

A) 21
B) 15
C) 9
D) 6
Question 14

A) 21
B) 15
C) 9
D) 6
Question 15
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Input a = 5, b = 6
2 if ( printf
3 print a
4 else
5 print b
6
7
8
9
10
11
12
13
14
Question 15

A) 0
B) 05
C) 5
D) 03
Question 15

A) 0
B) 05
C) 5
D) 03
Question 16
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer n = 5
2 for I = 1 to n;
3 print i
4 end for
5
6
7
8
9
10
11
12
13
14
Question 16

A) 1
B) 5
C) 6
D) Error
Question 16

A) 1
B) 5
C) 6
D) Error
Question 17
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer a = 11, b = 5
2 if ( a = 5)
3 b = 6
4 Print a
5 Print b
6
7
8
9
10
11
12
13
14
Question 17

A) 11 6
B) 11 5
C) 56
D) Compiler Error
Question 17

A) 11 6
B) 11 5
C) 56
D) Compiler Error
Question 18
What will be the output of the following pseudocode?
Code/Pseudo Code
1 if ( 0 )
2 print True
3 print False
4
5
6
7
8
9
10
11
12
13
14
Question 18

A) True
B) False
C) Error
D) No output
Question 18

A) True
B) False
C) Error
D) No output
Question 19
What will be the output of the following pseudocode?
Code/Pseudo Code
1 input a = 10, b = 10
2 x = a++
3 y = ++b
4 print x
5 print y
6
7
8
9
10
11
12
13
14
Question 19

A) 10 10
B) 11 11
C) 10 11
D) 11 10
Question 19

A) 10 10
B) 11 11
C) 10 11
D) 11 10
Question 20
What will be the output of the following pseudocode?
Code/Pseudo Code
1 input i = 0, j = 1, k = 2
2 m = i++ OR j++ OR k++
3 Print i
4 Print j
5 Print k
6 Print m
7
8
9
10
11
12
13
14
Question 20

A) 1234
B) 1221
C) 1131
D) 0121
Question 20

A) 1234
B) 1221
C) 1131
D) 0121
Question 21
What will be the output of the following pseudocode?
Code/Pseudo Code
1
2 int res = ch1 + ch2
3 print res
4
5
6
7
8
9
10
11
12
13
14
Question 21

A) 195
B) Error
C) 131
D) Undefined Behavior
Question 21

A) 195
B) Error
C) 131
D) Undefined Behavior
Question 22
What will be the output of the following pseudocode?
Code/Pseudo Code
1
2 character c = ch1 + ch2
3 Print c-32
4
5
6
7
8
9
10
11
12
13
14
Question 22

A) A
B) B
C) C
D) D
Question 22

A) A
B) B
C) C
D) D
Question 23
What will be the output of the following pseudocode if x=4?
Code/Pseudo Code
1 defined in preprocessing as square ( x ) x * x
2 integer i
3 i = 64 / square ( x )
4 print i
5
6
7
8
9
10
11
12
13
14
Question 23

A) 64
B) 16
C) 4
D) Garbage Value
Question 23

A) 64
B) 16
C) 4
D) Garbage Value
Question 24
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer a,b,v,c
2 set a=7, b=12,v=70
3 while(v>5)
4 a= a-v
5 c=(a+b)mod 10
6 while(c>7)
7 b=b+c
8 end while
9 v=v/2
10 end while
11 print b,c
12
13
14
Question 24

A) 14 -2
B) 12 -1
C) 16 82
D) 12 1
Question 24

A) 14 -2
B) 12 -1
C) 16 82
D) 12 1
Question 25
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer A[5][5],k,j;
2 for (k=0;k<5;++k)
3 for(j=0;j<5;j++)
4 A[k][j]=A[j][k]
5 end for
6 end for
7
8
9
10
11
12
13
14
Question 25

A) It makes the given matrix A, symmetric


B) None of the mentioned option
C) It transposes the given matrix A
D) Both A and C
Question 25

A) It makes the given matrix A, symmetric


B) None of the mentioned option
C) It transposes the given matrix A
D) Both A and C
Question 26
What will be the output of the following pseudocode?
Code/Pseudo Code
1 char str[20]
2 integer sameset
3 s=string length(str)
4 str[5]=NULL
5 s=strlen(str)
6 print s
7
8
9
10
11
12
13
14
Question 26

A) 5
B) 6
C) 4
D) Garbage Value
Question 26

A) 5
B) 6
C) 4
D) Garbage Value
Question 27
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer fun(Integer c)
2 print c
3 if(c<3)
4 c=c+2
5 fun(fun c)
6 end if
7 return c
8 end function fun
9
10
11 Value of c is 1
12
13
14
Question 27

A) 133
B) 13 5
C) 1
D) 3
Question 27

A) 133
B) 13 5
C) 1
D) 3
Question 28
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Read n
2 for(each k from 1 to n)
3 r = k mod 7
4 if (r NOT EQUALS 0)
5 print k
6 end if
7 end for
8
9
10
11
12
13
14
Question 28

A) To print all the integer from 1 to n which are multiple of 7

B) To print all the integer from 1 to n omitting those integers which are
divisible by 7
C) None of the mentioned option
D) To print all the integer from 1 to n which are divisible of 7
Question 28

A) To print all the integer from 1 to n which are multiple of 7

B) To print all the integer from 1 to n omitting those integers which are
divisible by 7
C) None of the mentioned option
D) To print all the integer from 1 to n which are divisible of 7
Question 29
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer i, sum
2 set i = 1,sum =0
3 sum = sum+i
4 if(sum>500)
5 print i
6 end if
7 else
8 i=i+1
9 Go to line number 3
10
11
12
13
14
Question 29

A) 64
B) 32
C) 16
D) 33
Question 29

A) 64
B) 32
C) 16
D) 33
Question 30
What will be the output of the following pseudocode if a=1 and b=2?
Code/Pseudo Code
1 dosometing(Integer a, integer b)
2 if (b EQUALS 1)
3 return 0
4 else
5 return a + dosometing(a,b-1)
6 end function dosometing()
7
8
9
10
11
12
13
14
Question 30

A) 2
B) 1
C) 3
D) 4
Question 30

A) 2
B) 1
C) 3
D) 4
Question 31
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer n,f0,f1,f,i
2 set n=5,f0=0,f1=3
3 for (each i from 1 to n)
4 f=f0+1
5 print f
6 f0 = f1
7 f1= f
8 end for
9
10
11
12
13
14
Question 31

A) 14253
B) 14257
C) 14357
D) 14353
Question 31

A) 14253
B) 14257
C) 14357
D) 14353
Question 32
What will be the output of the following pseudocode?
Code/Pseudo Code
1 integer n,a
2 set n=5,a=0
3 a=(n*(n+1))/2
4 n=n+a
5 print a
6
7
8
9
10
11
12
13
14
Question 32

A) 10
B) 5
C) 15
D) 20
Question 32

A) 10
B) 5
C) 15
D) 20
Question 33
What will be the output of the following pseudocode if n=2?
Code/Pseudo Code
1 Integer fun(Integer n)
2 if (n IS EQUAL TO 4)
3 return n
4 end if
5 else
6 return 2 *fun(n+1)
7 end function fun()
8
9
10
11
12
13
14
Question 33

A) 6
B) 16
C) 4
D) 2
Question 33

A) 6
B) 16
C) 4
D) 2
Question 34
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer a,b,
2 set a=2, b=12
3 c=b<<a
4 print c
5
6
7
8
9
10
11
12
13
14
Question 34

A) 48
B) 16
C) 4
D) 6
Question 34

A) 48
B) 16
C) 4
D) 6
Question 35
What will be the output of the following pseudocode?
Code/Pseudo Code
1 integer a,b,c,d set n=456 , a=0, b=1
2 while (n>0)
3 d=n mod 10
4 a=a+d
5 b=b*d
6 n=n/10
7 end while
8 print a
9 print b
10
11
12
13
14
Question 35

A) 15 120
B) 64 120
C) 12 24
D) None of the above
Question 35

A) 15 120
B) 64 120
C) 12 24
D) None of the above
Question 36
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer c,n
2 Set n=6
3 Set c=n
4 print c
5 c = c-2
6 if(c>0)
7 Go to the line number 4
8 end if
9
10
11
12
13
14
Question 36

A) 0246
B) 642
C) 024
D) 6420
Question 36

A) 0246
B) 642
C) 024
D) 6420
Question 37
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer n,b
2 for(each i from 1 to n)
3 b= i MOD 9
4 if(b EQUALS 0)
5 print i
6 End if
7 End for
8
9
10
11
12
13
14
Question 37

A) to print all number from 1 to n which is divisible by 9 only


B) to print all number from 1 to n which is divisible by 3,6 and 9
C) to print all number from 1 to n which is divisible by 3 and 9
D) None of the above
Question 37

A) to print all number from 1 to n which is divisible by 9 only


B) to print all number from 1 to n which is divisible by 3,6 and 9
C) to print all number from 1 to n which is divisible by 3 and 9
D) None of the above
Question 38
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer m,j,a[]
2 set a[]={2,3,5,7,1}
3 m=a[0]
4 for (j from 0 to 4)
5 if (m<a[j])
6 m=a[j]
7 end if
8 end for
9 print m
10
11
12
13
14
Question 38

A) 5
B) 2
C) 1
D) 7
Question 38

A) 5
B) 2
C) 1
D) 7
Question 39
What will be the output of the following pseudocode if n=99?
Code/Pseudo Code
1 Integer fun(Integer n)
2 if (n>100)
3 return n - 10
4 return fun (fun (n+11))
5 end function fun()
6
7
8
9
10
11
12
13
14
Question 39

A) 121
B) 91
C) 100
D) 110
Question 39

A) 121
B) 91
C) 100
D) 110
Question 40
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer a,b,cout,cout1
2 set a=2 ,b=3
3 while(a<=5)
4 b=2
5 while(b<=4)
6 b=b+2
7 cout1 = cout1+1
8 end while
9 a=a+1
10 cout=cout+1
11 end while
12 print cout,cout1
13
14
Question 40

A) 84
B) 48
C) 16 8
D) 81
Question 40

A) 84
B) 48
C) 16 8
D) 81
Question 41
What will be the output of the following pseudocode if the input given is
pqr
Code/Pseudo Code
1 fun(char *a)
2 If (*a EQUALS NULL)
3 return
4 end if
5 fun(a+1)
6 fun(a+1)
7 print *a
8 end function fun
9
10
11
12
13
14
Question 41

A) rrqrrqp
B) ppqqrr
C) rqppqr
D) none of the mentioned option
Question 41

A) rrqrrqp
B) ppqqrr
C) rqppqr
D) none of the mentioned option
Question 42
How many times A will be printed?
Code/Pseudo Code
1 Integer i,j,k,A
2 for(each i=0 to 4)
3 for(each j=0 to 2)
4 for(each k=0 to j-1)
5 print A
6 end for
7 end for
8 end for
9
10
11
12
13
14
Question 42

A) 15
B) 12
C) 16
D) 8
Question 42

A) 15
B) 12
C) 16
D) 8
Question 43
What will be the output of the following pseudocode if n=1?
Code/Pseudo Code
1 void reverse(int n)
2 if (n greater than 5)
3 exit
4 print n
5 return reverse(n++)
6 end function reverse()
7
8
9
10
11
12
13
14
Question 43

A) 12345
B) 12468
C) 12534
D) None of the above
Question 43

A) 12345
B) 12468
C) 12534
D) None of the above
Question 44
What will be the output of the following pseudocode ?
Code/Pseudo Code
1 Integer a,b,cout Set a=2,cout =0,b=1
2 while(b<121)
3 b=a*b
4 cout=cout+1
5 b=b+1
6 end while
7 print cout
8
9
10
11
12
13
14
Question 44

A) 6
B) 127
C) 120
D) 7
Question 44

A) 6
B) 124
C) 120
D) 7
Question 45
What will be the output of the following pseudocode?
Code/Pseudo Code
1 integer a,b,v,c
2 set a=7 ,b=12,v=70
3 while(v>5)
4 a=a-v
5 c=(a+b)mod 10
6 while(c>7)
7 b=b+c
8 end while
9 end while
10 print b,c
11
12
13
14
Question 45

A) Infinte loop
B) 12 4
C) 12 1
D) 12 7
Question 45

A) Infinite loop
B) 12 4
C) 12 1
D) 12 7
Question 46
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer a, b = 10
2 Set n = 2
3 for (each a from 1 to 6)
4 a = a + 2
5 end for
6 Print b
7
8
9
10
11
12
13
14
Question 46

A) 18
B) 10
C) 11
D) 14
Question 46

A) 18
B) 10
C) 11
D) 14
Question 47
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer a = 0
2 Set n = 2
3 for (each a from 1 to n)
4 a = a + 2
5 end for
6 Print a
7
8
9
10
11
12
13
14
Question 47

A) 4
B) 6
C) 2
D) 8
Question 47

A) 4
B) 6
C) 2
D) 8
Question 48
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer a = 0
2 Set n = 2, i = 0
3 if ( n % i == 0)
4 a = a + 2
5 end if
6 Print a
7
8
9
10
11
12
13
14
Question 48

A) Error
B) 6
C) 2
D) 8
Question 48

A) Error
B) 6
C) 2
D) 8
Question 49
What will be the output of the following pseudocode?
Code/Pseudo Code
1 Integer a = 10, b = 20
2 a = a XOR b
3 b = a XOR b
4 a = a XOR b
5 Print a
6 Print b
7
8
9
10
11
12
13
14
Question 49

A) 10 20
B) 20 10
C) 15 15
D) 1010 10100
Question 49

A) 10 20
B) 20 10
C) 15 15
D) 1010 10100
THANK YOU

You might also like