0% found this document useful (0 votes)
6K views180 pages

Infosys Pseudocode

Uploaded by

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

Infosys Pseudocode

Uploaded by

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

INFOSYS

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
1. Find the output of following pseudo code:
Set a=6, b=3, c=2
if(b>a && a>c && c>b)
b = a+1
else
a = b+1
print a+b+c
(a) 11
(b) 9
(c) 5
(d) Run time error

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
2. What will be the output of following code:
main()
{
while(!!7)
printf(“Hai”);
return 0;
}
(a) Hai
(b) HaiHai
(c) Infinite loop
(d) None of these

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
3. Find the output of following pseudo code :
int main()
{
long double a;
long double b;
int arr[sizeof(!a+b)];
printf(“%d”,sizeof(arr));
}
(a) Run time Error
(b) 32
(c) 64 with warning
(d) No output

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
4. Find the output of following pseudo code :
int main()
{
int x =4, y = 0;
int z;
z = (y++, y);
printf(“%d\n”, z);
return 0;
}
(a) 1
(b) 0
(c) Undefined Behavior due to order of evaluation can be different.
(d) Compilation Error

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
5. Find the output of following pseudo code:
Set j=1, k=1
for each i from 1 to 5 :
print(k)
j+=1
k+=j
end-for
(a) 1 2 3 4 5
(b) 4 6 8 10
(c) 1 1 2 3 5
(d) 1 3 6 10 15

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
6. Find the output of following pseudo code for values
a=10, b=6:
Func (Int a, Int b)
Int temp
while(b)
temp=aMODb
a=b
b=temp
end-while
return a
end-function
(a) 2 (b) 4 (c) 3 (d) 1
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
7. Find the output of following pseudo code:
int main()
{
int a =0,b=1,c=2;
*( ( a+1==1) ? &b : &a)= a? b : c;
printf(“%d, %d, %d \n”, a , b, c );
return 0;
}
(a) 0 1 2
(b) 0 2 0
(c) 0 2 2
(d) Error
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
8. Find the output of following pseudo code :
integer a = 40, b = 35, c = 20, d = 10
Comment about the output of the following two
statements:
print a * b / c – d
print a * b / (c – d)
(a) Differ by 80
(b) Same
(c) Differ by 50
(d) Differ by 160

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
9. Find the output of following pseudo code :
Consider the following code:
if (condition 1) {
if (condition 2)
{ // Statement A } else
if (condition 3)
{ // Statement B} else
{// Statement C } else
if (condition 4)
{// Statement D}
else
{// Statement E}

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
}
Which of the following condition will allow execution of
statement A?
(a) NOT(condition2) AND NOT(condition3)
(b) condition1 AND condition4 AND NOT(condition2) AND
NOT(condition3)
(c) condition1 AND condition2 AND condition4
(d) NOT(condition1) AND condition2 AND NOT(condition4)

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
10. Find the output of following pseudo code:
int main()
{
int num = 8;
printf (“%d %d”, num << 1, num >> 1);
return 0;
}
(a) 8 0
(b) 0 0
(c) 16 4
(d) Error : Can’t Perform operation

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
11. Find the output of following pseudo code :
int main()
{
int x = 2;
(x & 1) ? printf(“true”) : printf(“false”);
return 0;
}
(a) true
(b) false
(c) 0
(d) Error

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
12. What will be the output of following code :
int main()
{
int a = 4, b = 2;
printf(“a^b = %d”, a^b);
return 0;
}
(a) 4
(b) 1
(c) 0
(d) 6

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
13. What will be output of given pseudo code:
int j=41, k= 37
j=j+1
k=k-1
j=j/k
k=k/j
print(k,j)
(a) 42 36
(b) 36 1
(c) 1 1
(d) 1 36

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
14. integer a = 60, b = 35, c = -30
What will be the output of the following two statements:
print ( a > 45 OR b > 50 AND c > 10 )
print ( ( a > 45 OR b > 50 ) AND c > 10 )
(a) 0 and 1
(b) 0 and 0
(c) 1 and 1
(d) 1 and 0

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
16. Predict the output of the given pseudo code if the value
of number is 6
number = input()
k=2
i=2
while i <=number
k=k*i
i = i +1
end while
write k
(a) 1700 (b) 1560 (c) 1440 (d)
Error
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
17. What will be the output of the following for x = 0 to 27%
step 1 do
display x
end-for
(a) 0 1 2 3 4 5 6
(b) 0 1 2 3 4 5
(c) 1 2 3 4 5
(d) 0 1 2 3

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
18. What will be the output of following pseudocode?
Set integer y = 0
for z = 0 to 4:1 step 1 do
display – y
end for
(a) (-10)
(b) -1234.0
(c) (-1, -2, -3, -4)
(d) (0, -1, -2, -3)

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
19. Set Integer m=3
Set Integer n=5
Swith(m/m%n)
Case 1: m=m-n
Case 2: m+n
Case 3: m=m*n
Case 4: m=m/n
default.m=m
end-swith
display m
(a) 2 (b) 3 (c) Error (d) 15

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
20. What will be the output of following program?
Set float f=0.1
if (f==0.1) then do
display “Yes”
else
display “No”
end-if
(a) Varies in C C++ and Python
(b) No
(c) Yes
(d) Error

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
21. What will be the output of following pseudocode?
while(1*1*1==1*1*1)
display false
break
end-while
(a) 1
(b) true
(c) false
(d) error

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
22. Which of the following can be used to implement this
problem?
[Example: items are 5, 6, 1, the optimal choice is choose
1 then 5 then 6, the points gained is 6*1 + 1*6 + 1*1 =
13 points]
(a) Longest increasing subsequence
(b) Matrix chain multiplication
(c) Coin Exchange problem
(d) 0-1 Knapsack problem

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
23. Given alongside are two pseudo-class definitions in an Object-
Oriented Programming language. Which of the following
statements is true regarding the return type of Dog’s seekFood
() function?
Public class Animal{
protected Food seekFood(){
}
}
public class Dog extends Animal {
protected Food seekFood() {
return new DogFood();
}
}
(a) The code is an example of the use of virtual return type.
(b) The code is an example of the use of abstract return type
(c) The code is an example of the use of covariant return type.
(d) The
SMART codeRESOURCES
TRAINING is an example of the
INDIA PVT. LTD. use of ©contravariant return
2018 SMART Training Resources Pvt. Ltd.
24. You are using the code snippet {
given alongside 10 implement this. return false
What can be used in place of X
and Y such in the returns true if }
and only if the operation needs to function shrink (no size):
be applied. if (Y) {
(Example: Input size = 10 and no return true
= 10. The array is filled
}else{
completely and hence it should
double its sixe so the expansion return false }
function should) (a) X: no > size/4
(Note: The resizing or array is not Y : no < size/4
arbitrary, the expansion doubles (b) X : no == size
the size of array and the shrink
halves the size of array) Y: no < size/2

function expand (no, size); (c) X : no > size/2

if (X) Y : no < size/4

{ (d) X : no > size/2


Y : no < size/2
return true
SMART
}else TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
25. Which is the right answer of the following?
Suppose a circular queue of capacity (n - 1) elements is
implemented with array n of elements. Assume that the
insertion and deletion operation are carried out using
REAR and FRONT as anh array index variable,
respectively. Initially, REAR = FRONT =0
The condition to detect full and queue empty are
(a) Full: (REAR+1) mod n ==FRONT, empty: REAR ==
FRONT
(b) Full: (REAR+1) mod n ==FRONT, empty:
(FRONT+1) mod n == REAR
(c) Full: REAR ==FRONT, empty: (REAR+1) mod n ==
FRONT
(d) Full:
SMART (FRONT+1)
TRAINING mod
RESOURCES INDIA n ==REAR,© 2018
PVT. LTD. empty: REAR
SMART Training ==
Resources Pvt. Ltd.
26. Two robots are placed on anan infinite line at an unspecified distance
apart, and they must find each other. Which of the given pseudocode
must both of them follow if theyneed a meet?
[Note: Each instruction of pseudocode takes 1 second if perform and
the robots can only move left or right on the line]:
The robots will not meet in any of these cases
(a) 10 go right
20 go left
30 go right
40 goto 10
(b) 10 go right
20 Wait
30 go right
40 goto 10
(c) 10 go right
20 go left
30 go left
40 goto 10
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
27. What will the number of printed by the given pseudo code
when input is 25?
Write “please enter a number”
Read input
Repeat while input>0
If (star>0 and star<=10)
Write*
Else if(star>10 and star<=20)
Write*
Else if(star>20 and star<=30)
Write
Input
End if
End while
(a) 35.0 (b) 25.0 (c) 45.0
(d) 55.0
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
28. Predict the output of the given pseudo code if the value of n
is 35:
Read n
i=0
While n%10!=0
n=n+3
i++
end while
n=n+i
write n
Options
(a) 50.0
(b) 53.0
(c) 55.0
(d) 45.0
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
29. What will be the output of the given pseudo code if n = 10?
Read n
Initialize i to 5
while i < n do
increase sum by i
increment i
end while
Write sum
(a) 25.0
(b) 35.0
(c) 55.0
(d) 45.0

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
30. What will be the number of " * " printed by the given pseudo code when
input is 25?
Write "Please enter a number"
Read input
Repeat while input > 0
if( input > 0 and input <=10 )
Write *
else if ( input >10 and input <=20 )
Write **
else if ( input >20 and input< = 30 )
Write ***
input --
end if
end while
(a) 55.0 (b) 45.0 (c) 25.0 (d) 35.0

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
31. You have written the pseudo code given alongside for performing
binary search in an array of elements sorted in ascending order.
Which step to be followed in A to execute binary search
successfully?

1. Compare x with the middle element.

2. If x matches with the middle element, we return the mid index.

3. A

4. Else ( x is smaller ) recur for the left half

(a) Else if x is greater than the mid element, then x can only
lie in left half subarray after the mid element. So we recur for left

(b) Else if x is greater than the mid element, then x can only lie in
right half subarray after the mid element. So we recur for right

(c) Else if x is less than the mid element, then x can only lie in
right half subarray after the mid element. So we recur for right

(d) None of the given options


SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
32. You have a vehicle class, a car class, and a person class, you have
to implement the functionalities of a bird, dog, cat, bus, auto and 2
specialized car classes for hybrid and electric vehicles.
Which of these options is the most efficient way to do so?
1. Make a new class for all the required methods and implement all
methods separately.
2. Inherit the car class into the specialized car and then implement
the extra methods.
3. Make a new class Big vehicles and then inherit properties from
it to make the bus classes.
4. Inherit the person class to bird, dog, cat, and then override the
methods that are not required.
5. Make new class animals and use this to make the dogs, cats and
birds class.
6. Make a new three wheeled vehicle inherited from vehicle class
for auto.
7. Inherit vehicle class for auto.
(a) 2,5,7
SMART (b) 2,5,6
TRAINING RESOURCES INDIA PVT. LTD.(c) 3,4,6(d) 1
© 2018 SMART Training Resources Pvt. Ltd.
33. Class A contains two methods, namely “me” and
“see”. Class B inherits Class A and overrides the
“see” method. Class C also inherits methods from
Class A and overrides the “see” method. Class B
and class C are both inherited by class D using the
concept of multiple inheritances.
In the given scenario, identify the problem generated by
the behaviour of the “see” method?
(a) Dexterity problem
(b) Cohesion Problem
(c) Diamond Problem
(d) Coherence Problem

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
34. Consider the given problem statement:
Problem statement:
Find the closest pair of points in an array of distinct
points
Assume that you have solve this problem by comparing
all pairs of points. What will be the complexity of this
approach?
(a) O(N)
(b) O(N^2)
(c) O( N log N )
(d) Cannot be determined

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
35. You are using the pseduo algorithm given alongside to sort an
array using insertion sort.
Which of the following can be used in place of X to complete
the algorithm?
1. Declare static void insertionSortRecursive(int arr[], int n)
function.
2. if ( n < = 1 ) then return add more elements to array
message.
3. Sort first n-1 elements.
4. Insert last element at its correct position in sorted array
int last = arr[n-1];
int j= n-2;
5. Move elements of arr[X], that are greater than key, to one
position ahead of their current position.
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
36. What would be the output of the following code
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

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
37. What will be the output of the following pseudo code for arr[]=
1,2,3,4,5
initialize i,n
intialize and array of size n
accept the values for the array
for o to n
arr[i] = arr[i]+arr[i+1]
end for
print the array elements
(a) 3 5 7 9 5
(b) 3 5 7 9 11
(c) 3 5 9 15 20
(d) Error
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
38. What will be the output of the following Code ?
#include<stdio.h> f = f1 + f2;

int main( ) f2 = f1;

{ f1 = f;

int n=5, k, f1, f2, f; }

if ( n < 2 ) printf("%d",f) ;

return n; }

else }

{ (a) 8

f1 = f2 = 1; (b) 5

for(k=2;k<n;k++) (c) 13

{ (d) 7

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
39. 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++)
{

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
if (array[j] < array[min_idx])
min_idx = j;
}
temp = array[min_idx];
array[min_idx] = array[i];
array[i] = temp;}
(a) finding a specific element of an array
(b) finding smallest element of an array
(c) Sorting the elements of an array
(d) None of the above

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
40. What will be the output of the following pseudo code?
#include<stdio.h> {
int fun(int x, int y); if(x<=0)
int main() return y;
{ else
int i,n; return(fun(x-1,y-1));
i=5; }
n=7; (a) 0
int f = fun(5,7); (b) 1
printf("%d", f); (c) 2
} (d) 3
int fun(int x, int y)

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
41. What is the output?
#include<stdio.h>
using namespace std;
int main()
{
for (int x = 10; x >= 0; x--) {
int z = x & (x >> 1);
if (z)
printf("%d ", x);
}
}
(a) 7 6 3 (b) 7 6 9 (c) 678
(d) 679
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
42. What is the output?
#include<stdio.h>
int main()
{
int a = 100;
printf("%0 %x", a);
}
(a) %a
(b) %x
(c) 100
(d) None of these

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
43. What is the output?
#include<stdio.h>
int main()
{
typedef int num;
num bunk = 0.00;
printf("%d", bunk);
return 0;
}
(a) Zero (b) 0.0
(c) garbage value (d) Logical Error

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
44. What is the output?
#include<stdio.h>
int main(){
float x = 0.0;
long int y = 10;
printf("%d", sizeof(y) == sizeof(x+y));
return 0;
}
(a) 1
(b) zero
(c) 4
(d) 8
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
45. What is the output?
#include<stdio.h>
int main()
{
int any = ' ' * 10;
printf("%d", any);
return 0;
}
(a) 320
(b) 340
(c) 360
(d) 380
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
46. What will be the output of the following pseudocode:
#include<stdio.h>
int main()
{
int go = 5.0, num = 1*10;
do
{
num /= go;
} while(go--);
printf ("%d\n", num);
return 0;
}
(a) Floating Point Exception (b) Compilation Error
(c) 3 6 7 (d) None of these
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
47. What will be the output of the following pseudocode:
#include <stdio.h>
int main()
{
int num = 987;
int rem;
while(num!=0)
{
rem = num % 4;
num = num / 10;
}
printf("%d",rem);
}
(a) zero (b) 1 (c) 2 (d) 3
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
48. What will be the output of the following Pseudo Code.
#include<stdio.h>
int main()
{
float i;
i = 1;
printf("%d",i);
return 0;
}
(a) 1
(b) Garbage Value
(c) 1.000000
(d) Error

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
49. What will be the output of the following pseudocode:
public class Main
{
public static void main(String[] args)
{
String names[] = new String[5];
for(int x=0; x<args.length; x++)
names[x] = args[x];
System.out.println(names[2]);
}
}
(a) Names (b) Null
(c) Compilation fails (d) An exception throws at
runtime
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
50. What will be the output of the following pseudocode for a = 0,
b = 0?
Integer funn(Integer a, Integer b)
if(a)
return a
End if
if(b)
return b
End if
return a + 1 + b – a + b
End function funn()
(a) 3
(b) 0
(c) 1
(d) 2
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
51. What will be the output of the following pseudocode?
Integer a, b, c a=b+1
Set b = 100, a = 1 b=a–1
for(each c from 1 to 2) a=a–1
a = (a + a) * a End if
b = b – 10 Print a
End for [Note: If(x) gets executed
if the value inside if(), i.e.,
if(1)
x is not zero]
b=a–1
(a) 25
a=a–1
(b) 8
a=b+1
(c) 20
Else
(d) 9
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
52. What will be the output of the following pseudocode for a = 2?
Integer sum(Integer a)
if(a equals 1)
return 1
else
return (a * a + sum(a – 1))
End function sum()
(a) 2
(b) 5
(c) 1
(d) 6

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
53. What will be the output of the following pseudocode?
Integer j, m
Set m = 1
Integer a[4] = {1, 1, 2, 2}
a[0] = a[0] + a[1] + a[2] + a[3]
a[1] = a[0] + a[1] + a[2] + a[3]
a[2] = a[0] + a[1] + a[2] + a[3]
a[3] = a[0] + a[1] + a[2] + a[3]
m = a[3]
Print m
(a) 20 (b) 40 (c) 45 (d) 30

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
54. How many times the following pseudocode will print hello?
Integer k, p, j
set k = 1, p = 4
int j = p + k/2
if(j equals p)
print “hello”
end if
j = p + k/5
if(j not equals p)
print “hello”
end if
print “hello”
(a) One time (b) Two times
(c) Three times (d) Will not print hello at all
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
55. What will be the output of the following pseudocode?
Integer arr[] = {110, 120, 130, 140, 15}
Integer k
Set k = arr[3] – arr[1]
if(k < 25)
arr[3] = 10
End if
Print (k + arr[3])
(a) 30
(b) 40
(c) 10
(d) 20

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
56. What will be the output of the following pseudocode?
Integer a, b Print a + b
Set b = 0 [Note- &&: Logical AND -
The logical AND operator
Set a = b + 3
(&&) returns the Boolean
if(a && b) value true(or 1) if both
a=a–2 operands are true and
return false (or 0)
End if
otherwise.
if(a)
If(x) gets executed if the
a=1 value inside if(), i.e., x is
b=1 not zero.]

End if (a) 2

a=b (b) 8
(c) 6
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
57. What will be the output of the following pseudocode?
Integer a, b, c, d
Set a= 3, b = 1
for(each d from 1 to 3)
for(each c from 1 to 2)
if(c < d + 1)
a=a–b
Else
a=a+b
End if
End for
End for
Print a
(a) – 1 (b) 7 (c) 3 (d) – 2

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
58. What will be the output of the End function Display()
following pseudocode for input = (a) Before Modifying :
“Hello” and counter = 0? Hello
String Display(string input, After Calling
integer counter) Display() : Hello test
print “Before Modifying”, input (b) Before Modifying :
while (counter <= 2) Hello
if(input EQUALS “Hello”) Before Modifying :
input = input + “test” Hello test
else Before Modifying :
counter = counter + 1 Hello test
input = input + Display(input, Before Modifying :
counter) Hello test
end if After Calling
counter = counter + 1 Display() : Hello testHello
end while test Hello testtest
return input; (c) Before Modifying :
Hello
Before Modifying :
Hello test
Before Modifying :
Hello test
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources
After Calling Pvt. Ltd.
59. Consider a linked list: 1 -> 3 -> 2 -> 1 -> 1, consisting of 5
nodes. It is given that it is a circular linked list. It is given that
the node pointer p, points to the first node initially.
i = 0, sum = 10
while(i not equals 4)
sum = sum + p -> data
p = p -> next
p = p -> next
i=i+1
What will be the value of sum, after the above code has been
executed?
(a) 10 (b) 9 (c) 17 (d) 5

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
60. Consider an array S of integers:
S = {1, 11, 111, 1, 111, 1, 11, 11, 11}
The following operations are performed on the array:
1) 1 is appended.
2) S[0] and S[–1] are swapped with each other
3) S[1] and S[–2] are swapped with each other
What will be the second element of the array S?
(a) None of the mentioned options
(b) 111
(c) 11
(d) 1

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
61. What is the output of this C code?
#include<stdio.h>
int main()
{
int a = 1;
if (a--)
printf(“True”);
if (a++)
printf(“False”);
return 0;
}
(a) True (b) False (c) Nothing will print
(d) True False
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
62. What will be the output of the following pseudocode?
Integer p, q, r
Set p = 2, q = 2, r = 1
p = p + (p ^ p)
q = q + (p ^ p)
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 operand. If one bit is 0 and the other bit is 1, the
corresponding result bit is set to 1. Otherwise, the
corresponding result bit is set to 0.]
(a) 10 (b) 13 (c) 5 (d) 2

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
63. Consider the following pseudocode: (It is given that p points to the
first element of the linked list: 4 -> 5 -> 6 -> 8)
struct Node{
int data;
struct Node *next;
};
void fun(struct Node *p){
if(p! = NULL) {
fun(p -> next)
print (p -> data)
}
}
What will be the output?
(a) 6 8 4 5 (b) 5 4 6 8 (c) 4 5 6 8 (d) 8 6 5
4
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
64. What will be the output of the following pseudocode?
Integer p, q, r
Set p = 1, q = 4, r = 3
if(p & q && q & r)
p=q+r
if(p > q)
p=q
End if
End if
Print p + q + r
[Note- &&: Logical AND - The logical AND operator (&&) returns the
Boolean value true(or 1) if both operands are true and return false (or
0) otherwise.
&: bitwise AND - The bitwise AND operator (&) compares each bit of
the first operand to the corresponding bit of the second operand. If
both bits are 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) 4 (b) 19 (c) 12 (d) 8
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
65. What will be the output of the following pseudocode?
Integer p, q, r
Set p = 18, q = 3, r = 14
if(p < q)
p=q+q
Else
q=p
if(r > q)
r=q+q
Else
q=r+r
End if
End if
Print p + q + r
(a) 55 (b) 64 (c) 72 (d) 60

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
66. What will be the output of the following pseudocode for a = 1, b =
1?
Integer funn(Integer a, Integer b)
Integer c
for(each c from 2 to 6)
a=a+b
if(a < c)
Jump out of the loop
End if
b=c
End for
return a + b
End function funn()
(a) 22 (b) 19 (c) 26 (d) 30
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
67. What will be the output of the following pseudocode for a = 9, b =
7?
Integer funn(Integer a, Integer b)
if(b ^ b > a ^ a)
a=a^a
Else
b=b^b
End if
return a + b
End function funn()
[Note-^ 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 0 and the other bit is 1, the corresponding
result bit is set to 1. Otherwise, the corresponding result bit is set
to 0]
SMART © 2018 SMART Training Resources Pvt. Ltd.
(a) 16TRAINING RESOURCES INDIA PVT. LTD.(c)
(b) – 10 18 (d) 7
68. What will be the output of the following pseudocode?
Integer p, q, r
Set p = 4, q = 2, r = 2
p=p+q–2
q=q+r–2
if (r > p && q > p)
p=0
q=p
End if
Print p + q
[Note- &&: Logical AND - The logical AND operator (&&) returns
the Boolean value true(or 1) if both operands are true and return
false (or 0) otherwise.
If(x) gets executed if the value inside if(), i.e., x is not zero.]
(a) 10 (b) 6 (c) 20 (d) – 9
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
69. What will be the output of the following pseudocode?
Integer x, y, z
set x = 19, y = 55
z=x+y/7
if(z + 1 >= 8)
x=x+1
else
y=y+1
end if
print z + x
(a) 46 (b) 89 (c) 34 (d) 45

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
70. What will be the output of the following pseudocode?
String s1 = “testing”
Integer k
for (each k from s1.length-1 to 0)
Print s1[k]
[Note: string.length - counts the number of characters in
a given string and returns the integer value.]
(a) gnitset
(b) 7
(c) testing
(d) 2

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
71. What will be the output of the following pseudocode?
Integer j, m
Set m = 1
Integer a[4] = {1, 1, 3, 12}
if (a[0])
m = m + a[3] – a[2] + a[1] – a[0]
Else
m = m + a[3] + a[2] – a[1] + a[0]
End if
Print m
[Note: If(x) gets executed if the value inside if(), i.e., x is not
zero]
(a) 10 (b) 1 (c) 5 (d) 7
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
72. What will be the output of the following pseudocode?
Integer p, q, r
Set p = 7, q = 2, r = 7
p=p+q
q=q+r
if(q + r)
if(p + r)
p=q
if(r + q)
p=r
End if
r=p
End if
End if
Print p + q + r
[Note: If(x) gets executed if the value inside if(), i.e., x is not zero]
(a) 21 (b) 23 (c) 33 (d) 25
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
73. What will be the output of the following pseudocode?
Integer a, b, c
Set a = –3, b = 0
if(b + a < b)
if(1)
for (each c from 0 to 2 – 1)
a=b+4
End for
End if
End if
Print a + b
[Note: If(x) gets executed if the value inside if(), i.e., x is not zero]
(a) 1 (b) 2 (c) 4 (d) 6

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
74. What will be the output of the following pseudocode?
Integer a, b
Set a = 3, b = 7
if (b)
a = a mod (a – 1)
b = b mod (b – 1)
End if
Print a + b
[Note- mod finds the remainder after the division of one
number by another. For example, the expression “5 mod 2”
would evaluate to 1 because 5 divided by 2 leaves a quotient of
2 and a remainder of 1.]
(a) 0 (b) 3 (c) 2 (d) 13
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
75. What will be the output of the following pseudocode?
Integer p, q, r
Set p = 9, q = 7, r = 1
if(p < p + r)
if(p > p + p)
p=p+p
End if
if(q > p – r)
q=p–r
End if
q=q–p
End if
Print p + q + r
(a) 8 (b) 15 (c) 3 (d) 17

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
76. What will be the output of the following pseudocode?
Integer x, y
Set x = 56
y = x + 8 – 76 / 9 * 3 / 7 – 57 / 2 & 1
if(y)
print “h”
else
print “b”
end if
[Note: If(x) gets executed if the value inside if(), i.e., x is not
zero]
(a) None of the mentioned options (b) No output
(c) h (d) b
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
77. What will be the output of the following pseudocode for a = 2,
b = 2?
Integer funn(Integer a, Integer b)
if(a > 0 && b > 0)
return funn(0, 0) + funn(–7, 10) + funn(a – 1, a – 1)
End if
return a + b
End function funn()
[Note- &&: Logical AND - The logical AND operator (&&)
returns the Boolean value true(or 1) if both operands are true
and return false (or 0) otherwise.
If(x) gets executed if the value inside if(), i.e., x is not zero.]
(a) 8 (b) 6 (c) 7 (d) 4
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
78. Traffic Lights
Now, Xinyou is quite well versed with the driving skills. He now
has to learn the traffic signals. Write a C program that instructs
Xinyou in this regard.
Input and output format:
Input consists of a string ‘s’ corresponding to the color of the
traffic light red, yellow or green.
Output consists of a single line, a string ‘Go’, ‘Stop’, Get Ready’ or
‘Invalid Input’.
Sample
Assume that the input consists of lowercase Outputonly.
characters 2:
Sample Input 1: Invalid Input
red Sample Input 3:
Sample Output 1: Blue
Stop Sample Output 3:
Sample Input 2: Invalid Input
blue TRAINING RESOURCES INDIA PVT. LTD.
SMART © 2018 SMART Training Resources Pvt. Ltd.
79. What will be the output of the following pseudocode?
Integer a, b, c
Set a = 3, b = 2, c = 4
if ((b < 6 & 6 & 6 && a > 6 & 6 || (c > b || a > c))
a=6&6&6&6
End if
if (6 & 6 & 6)
a=6&6&6
End if
Print a + b + c
[Note- &&: Logical AND - The logical AND operator (&&)
returns the Boolean value true(or 1) if both operands are true
and return false (or 0) otherwise.
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
79. &: bitwise AND - The bitwise AND operator (&) compares each
bit of the first operand to the corresponding bit of the second
operand. If both bits are 1, the corresponding result bit is set
to 1. Otherwise, the corresponding result bit is set to 0.
||: Logical OR – The logical OR operator (||) returns the boolean
value TRUE(or 1) if either or both operands is TRUE and
returns FALSE(or 0) otherwise
If(x) gets executed if the value inside if() i.e., x is not zero]
(a) 14
(b) 12
(c) 31
(d) 8

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
80. What will be the output of the following pseudocode?
Integer a, b, c
Set a = 1, b = 1, c = 5
a = a mod 5
b = a mod 5
c = a mod 5
Print a + b + c
[Note- mod finds the remainder after the division of one
number by another. For example, the expression “5 mod 2”
would evaluate to 1 because 5 divided by 2 leaves a quotient of
2 and a remainder of 1]
(a) 4 (b) 6 (c) 3 (d) 5

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
81. What will be the output of the following pseudocode?
String str1 = “mo”, str2 = “Om”
Print countConso(lower(str1)) + countVowel(lower(str2))
[Note: countConso(string) returns the number of consonants in
the string. Ex- countConso(“okay”) returns 2
countVowel(string) returns the number of vowels in the string.
Ex- countVowel(“okay”) returns 2
lower(string) converts all the letters of the string to lower case.
Ex- lower(“OkaY”) would return “okay”]
(a) 4
(b) 3
(c) 1
(d) 2
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
82. What will be the output of the following pseudocode?
Integer arr[] = {1, 2, 3}
Integer a, s
Set s = 0
for (each a from 3 to 5)
s = s + arr[a – 3]
End for
Print s
(a) 4
(b) 2
(c) 6
(d) 1

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
83. What will be the output of the following pseudocode?
Integer a, b, c End for

Set a = 1, b = 2 Print b + a

for (each c from 216 to 217) [Note- &&: Logical AND -


The logical AND operator
if(c – 200 > 100)
(&&) returns the Boolean
if(1 && 1) value true(or 1) if both
operands are true and
a=a+c
return false (or 0)
End if otherwise.
a=a+c If(x) gets executed if the
Else value inside if(), i.e., x is
not zero]
a=0
(a) 7 (b) 2
End if
(c) 4 (d) 8
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
84. For which of the following options, the pseudocode will print the
square of variable ‘a’?

Integer a

if(a mod 2 not equals 0)

if(a > 12)

print a * a

end if

end if

[Note: mod finds the remainder after the division of one number by
another. For example, the expression “5 mod 2” would evaluate to
1 because 5 divided by 2 leaves a quotient of 2 and a remainder of
1]

(a) When the value of variable ‘a’ is even (b) None of the
mentioned options

(c) When
SMART the RESOURCES
TRAINING value of variable ‘a’ is
INDIA PVT. LTD. odd (d) ©When theTraining
2018 SMART value of a =
Resources Pvt. Ltd.
85. What will be the output of the following pseudocode?
Integer a, b, c
Set a = 1, b = 1
for (each c from 5 to 7)
a=a–1
if(a & b)
a=a+1
Continue
End if
a=a+2
End for
Print b + a
[Note- Continue: When a continue statement is encountered inside a loop,
control jumps to the beginning of the loop for next iteration, skipping the
execution of statements inside the body of the loop for the current
iteration
&: bitwise AND – The bitwise AND operator (&) compares each bit of the
first operand to the corresponding bit of the second operand. If both bits
are 1, the corresponding result bit is set to 1. Otherwise, the
corresponding result bit is set to 0.]
(a) 3 (b) 2 (c) 8 (d) 9
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
86. After the following code:
int i = 2;
int k = 4;
int* p1;
int* p2;
p1 = &i;
p2 = &k;
*p1 = *p2;
*p1 = 6;
*p2 = 8;
What is the value of i?
(a) 2 (b) 6 (c) 4 (d) 8

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
87. What will be the output of the following pseudocode?
Integer a, b, c
Set a = 10, b = 1, c = 3
a=a–c
if ((a + 10) && (c – 3))
a = 1110
End if
Print a + c – b
[Note- &&: Logical AND - The logical AND operator (&&)
returns the Boolean value true(or 1) if both operands are true
and return false (or 0) otherwise.]
(a) None of the mentioned options (b) 4
(c) 9 (d) 2

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
88. What will be the output of the following pseudocode?
Integer pp, qq, rr
Set pp = 2, qq = 2, rr = 3
rr = rr & pp
qq = rr & pp
pp = rr & pp
Print pp + qq + rr
[Note- &: bitwise AND - The bitwise AND operator (&)
compares each bit of the first operand to the corresponding bit
of the second operand. If both bits are 1, the corresponding
result bit is set to 1. Otherwise, the corresponding result bit is
set to 0.]
(a) 15 (b) 6 (c) 3 (d) 13

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
89. What will be the output of the following pseudocode for a = 2,
b = 6?
Integer funn(Integer a, Integer b)
if(b – a > 0)
return b + funn(a + 2, b – 2)
Else
return a + b
End if
return a – b
End function funn()
(a) 8 (b) 29 (c) 16 (d) 14

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
90. What will be the output of the following pseudocode?
Integer a, b, c a=a+2

Set b = 40, a = 20, c = 20 c=a+2

if (c > (c + a)) End if

b=0 Print a + b + c

Else (a) 19

a=a+2 (b) 3

c=a+2 (c) 90

End if (d) 5

if (c > (b + a))
b=0
Else

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
91. What will be the output of the following pseudocode?
Integer a, b, c
Set a = 1, b = 1
for (each c from 1 to 3)
a=a–c
b=b+c+a
b = b mod 5
End for
Print a + b
[Note- mod finds the remainder after the division of one
number by another. For example, the expression “5 mod 2”
would evaluate to 1 because 5 divided by 2 leaves a quotient of
2 and a remainder of 1.]
(a) – 4 (b) 3 (c) – 5 (d) – 7
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
92. What will be the output of the following pseudocode for a = 10,
b = 10?
Integer funn(Integer a, Integer b)
if(b && a)
return 3 + funn(0, 2) + funn(b – 5, 0)
End if
return a + b
End function funn()
[Note- &&: Logical AND - The logical AND operator (&&)
returns the Boolean value true(or 1) if both operands are true
and return false (or 0) otherwise.
If(x) gets executed if the value inside if(), i.e., x is not zero.]
(a) 10 (b) 2 (c) 3 (d) 6
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
93. What will be the output of the following pseudocode for a = 2,
b = 2?
Integer funn(Integer a, Integer b)
Integer c
for(each c from –2 to 2)
a=a+c
End for
if(a < 10)
if(a < 5)
return a + b
End if
return a
End if
return a + 1
End function funn()
(a) 5 (b) 3 (c) 7 (d) 4
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
94. Which of the following operations will be used in the missing
place such that the output would be 12?
Integer 1, b, a, p
set 1 = 8, b = 4
a=1+b
p=2+1+b
b=b–1
print p… _ _ _ _ _ _ _ _ _ b
(a) &&
(b) >>
(c) *
(d) &

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
95. What will be the output of the following pseudocode?
string first, second
set first = “Welcome”
second = first
first = first + “User”
print second
(a) User
(b) Welcome User
(c) Welcome
(d) first

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
96. What will be the output of the following pseudocode?
Integer a, b, c
Set a = 4, b = 1, c = 3
b = b mod (1 + (a mod 1 + (c mod 2)))
Print a + b + c
[Note- mod finds the remainder after the division of one
number by another. For example, the expression “5 mod 2”
would evaluate to 1 because 5 divided by 2 leaves a quotient of
2 and a remainder of 1]
(a) 15
(b) 7
(c) 8
(d) 24
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
97. What will be the output of the following pseudocode?
Integer j, m
Set m = 0
Integer a[4] = {4, 3, 2, 1}
for(each j from 0 to 3)
if((j > 2) || (a[j] > 2))
m = m * a[j]
End if
End for
Print m
[Note: ||: Logical OR - The logical OR operator (||) returns the
boolean value TRUE(or 1) if either or both operands is TRUE
and returns FALSE(OR 0) otherwise
If (x) gets executed if the value inside if(), i.e., x is not zero]
(a) 2 (b) 0 (c) 1 (d) 4
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
98. What will be the output of the following pseudocode?
Integer a, b, c
Set a = 8, b = 1
for (each c from 4 to 6)
a=a+1
if(6 > 7)
a=a+1
Else
Jump out of the loop
End if
End for
Print a + b
(a) 14 (b) 13 (c) 12 (d) 10

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
99. What will be the output of the following pseudocode for a = 3,
b = 2?
Integer funn(Integer a, Integer b)
if(8 > 3)
a=2
Else
b=2
End if
return a + b
End function funn()
(a) 4 (b) 6 (c) 15 (d) – 1

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
100. What will be the output of the following pseudocode?
Integer a, b, c
Set a = 3, b = 6, c = 9
a=b^a
b=a^b
a=a^a
c=b^c
Print a + b + c
[Note-^ 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 0 and the other bit is 1, the
corresponding result bit is set to 1. Otherwise, the
corresponding result bit is set to 0]
(a) 17 (b) 10 (c) 23
SMART TRAINING RESOURCES INDIA PVT. LTD.
(d) 13
© 2018 SMART Training Resources Pvt. Ltd.
101. What will be the output of the following pseudocode?
Integer a, b, c, d, i
Set a = 1, b = 0, c = 6, d = 7
for(each i from 0 to 3)
if(a OR b OR c AND d)
print a + 1
end if
if(a equals 2)
print a + 1
end if
if(a equals 1)
jump out of the loop

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
end if
end for
print “journey”
[Note- &&: Logical AND - The logical AND operator (&&)
returns the Boolean value true(or 1) if both operands are true
and return false (or 0) otherwise.
||: Logical OR - The logical OR operator (||) returns the boolean
value TRUE(or 1) if either or both operands is TRUE and
returns FALSE(OR 0) otherwise]
(a) 1 2
(b) 1 2 journey
(c) 2 journey
(d) 1 2 3 4 5126.

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
102. What would be the output of the following pseudocode?
Integer p, q, r, s
Set p = 3
for (each s from 0 to 2)
p=p+s
for (each r from 0 to 2)
p=p+r
End for
for (each q from 0 to 2)
p=p+q
End for
End for
Print p + q + r
(a) 31 (b) 40 (c) 28 (d) 30

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
103. What would be the output of the following pseudocode?
Integer a, b, c
Set b = 2, c = 1
for(each a from 3 to 5)
b=b+1
c=c+b
End for
Print a + b + c
(a) 7
(b) 3
(c) 24
(d) 5

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
104. What would be the output of the following pseudocode?
Integer j, m
Set m = 2, j = 2
Integer a[6] = {6, 6, 6, 3, 3, 3}
a[1] = a[1] – a[2]
if(a[1] > 0)
a[1] = 1
Else
a[2] = 2
a[3] = 3
End if
m = a[1 + m] + a[j]
Print m
(a) 12 (b) –3 (c) 5 (d) 22

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
105.What would be the output of the following pseudocode?
Integer a, b, c
Set b = 5, a = 2, c = 2
if (a)
a=a–1
a=c
Else
c=c+1
End if
if (a)
c=c+1
Else
c=c+1
End if
Print a + c
[Note: If(x) gets executed if the value inside if(), i.e., x is not zero]
(a) 5 (b) 3 (c) 4 (d) 9

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
106. What would be the output of the following pseudocode?
Integer x, y, p
set x = 17, y = 89
p=x^y
x=x–5
y=y–7
print p
[Note-^ 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 0 and the other bit is 1, the
corresponding result bit is set to 1. Otherwise, the
corresponding result bit is set to 0]
(a) 45 (b) 96 (c) 87 (d) 94

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
107. How many times the while loop in the following
pseudocode will print the value of variable p?
Integer p, a, b
set a = 67, b = 43
p=a&b
while(p not equals 0)
print p
p=p–1
end while
[Note: & - Bitwise AND operator, it takes two numbers as
operands and does AND on every bit of two numbers. The
result of AND is 1 only if both bits are 1]
(a) 2 times (b) 43 times (c) 67 times (d) 3
times
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
108. Consider a graph G with 10 vertices. Which of the
following can be the number of edges in the graph if it is given
that the edge connectivity of the graph is zero?
(a) 40
(b) 20
(c) 4
(d) 18

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
109. What will be the output of the following pseudocode?
Integer p, q, r p=r+q
Set p = 12, q = 91, r = 4 End if
if(p + 20 > q + 144) Print p + q + r
q=p (a) 194
Else (b) 190
if(q > 100) (c) 182
r=q (d) 201
q=p
Else
p=r
End if

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
110. Which of the following statements is true for the given
pseudocode?
Integer n[10], a, 1
for(each a from 0 to 8)
if(n[a] is greater than equal to 2 AND n[a] is less equal to 8)
1 = 1 + n[a]
end for
print 1
[Note- &&: Logical AND - The logical AND operator (&&) returns
the Boolean value true(or 1) if both operands are true and return
false (or 0) otherwise.]
(a) The pseudocode will compute the sum of all the array
elements
(b) The pseudocode will compute the sum of first and last
array elements
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
111. What will be the output of the following pseudocode?
Integer a, b, c
Set a = 10, b = 4
Set c = a + b
c=c–a–b
a=b
c=c+b+a
Print c
(a) 5
(b) 6
(c) 9
(d) 8

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
112.What will be the output of the following pseudocode?
r=1
Integer p, q, r
p=r
Set p = 12, q = 1, r = 3
End if
if(q < p)
q=r
p=q
End if
q=r
Print p + q + r
r=p
[Note: If(x) gets executed if
if(p)
the value inside if(), i.e., x is
r=q not zero]
p=q (a) 19
End if (b) –2
q=r (c) 8
r=p (d) 3
if(r)
q=1
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
113. What will be the output of the following pseudocode for
a = 8, b = 2?
Integer funn(Integer a, Integer b)
if(a > 0)
return a + b + funn(a – 5, b) + funn(a – 5, b – 1) + funn(a – 5, b
– 2)
End if
return a
End function funn()
(a) 6
(b) 4
(c) 14
(d) –2
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
114.What will be the output of the following pseudocode?
Integer pp, qq, rr
Set pp = 5, qq = 7, rr = 4
if(pp)
if(qq + qq > pp + pp)
pp = 1
End if
if(qq > 1)
rr = 1
End if
qq = pp
End if
Print pp + qq + rr
[Note: If(x) gets executed if the value inside if(), i.e., x is not zero]
(a) 3 (b) 5 (c) 2 (d) 13
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
115. What will be the output of the following pseudocode?
Integer pp, qq, rr, ss
Set pp = 4, qq = 2
for (each rr from 1 to 3)
if(pp > rr)
for (each ss from – 2to 0)
pp = pp + ss
qq = qq + rr
End for
End if
pp = pp + rr
End for
Print pp + qq
(a) 22 (b) 31 (c) 18 (d) 15

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
116. What will be the output of the following pseudocode for
a = 9, b = 2?
Integer funn(Integer a, Integer b)
Integer c
for (each c from 0 to 2)
a=a+c
b=b+c
End for
return a + b
End function funn()
(a) 12 (b) 17 (c) 19 (d) 25

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
117. What will be the output of the following pseudocode for
a = 1, b = 1?
Integer funn(Integer a, Integer b)
a=a–1
a=a–b
if(b > 2)
a = 11
Else
b = 11
End if
b=b–2
b=b–a
return a + b
End function funn()
(a) 10 (b) 17 (c) 9 (d) 7
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
118. Consider the input for the below code is 2, 2, 1, 2, 3, 4 and
predict the output
import java.util.Scanner;
public class JavaProgram
{
public static void main(String args[])
{
int row, col, i, j;
int arr[][] = new int[10][10];
Scanner scan = new Scanner(System.in);
row = scan.nextint();
col = scan.nextint();
for(i=0; i<row; i++)
{
for(j=0; j<col; j++)
{
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
arr[i][j] = scan.nextint();
}
}
for(i=0; i<row; i++)
{
for(j=0; j<col; j++)
{
System.out.print(arr[i][j]+ “”);
}
System.out.println();
}
}
(a) 12 (b) 3 4
34 12
(c) 13 (d) None of the listed options
24

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
119. What will be the output of the following pseudocode?
Integer j, m
Set m = 1, j = 2
Integer a[6] = {3, 2, 1, 0, 1, 2}
a[m] = m + a[m] + m
m=m+j
a[m] = m + a[m] + m
m=m+1
m = a[0] + a[1] + a[2] + a[3]
Print m
(a) 22 (b) 14 (c) 13 (d) 17

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
120. What will be the output of the following pseudocode for
a = 122, b = 141?
Integer funn(Integer a, Integer b)
if(1)
if(0)
return a + b
Else
return a + 2 * b
End if
Else
return a * b
End if
return 8
End function funn()
[Note: If(x) gets executed if the value inside if(), i.e., x is not
zero]TRAINING RESOURCES INDIA PVT. LTD.
SMART © 2018 SMART Training Resources Pvt. Ltd.
121. What will be the output of the following pseudocode?
Integer p, q, r, s
Set p = 2, q = 0
for (each r from 0 to 2)
p=p+p
for (each s from 0 to 2)
p=p&s
if(r + s > 2)
Jump out of the loop
End if
End for
End for
Print p + q
[Note- &: bitwise AND - The bitwise AND operator (&) compares each bit
of the first operand to the corresponding bit of the second operand. If
both bits are 1, the corresponding result bit is set to 1. Otherwise, the
corresponding result bit is set to 0.]
(a) –4 (b) 0 (c) 6 (d) 9

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
122. What will be the output of the following pseudocode?
float a = 30.3f
Print “test”
Print a
[Note: float - These are used to hold real numbers, floating-
point numbers can also be represented in exponential.]
(a) 30.3 (b) test
test 30.3f
(c) 30.3f (d) test
Test 30.3

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
123. What will be the output of the following pseudocode?
Integer a, b, c
Set a = 1, b = 3, c = 2
if(0 || 1)
a=a+c
if(0 && 1)
a=a+c
End if
if(0 && 1)
a=a–c
if(0 || 1)
a=a+c

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
End if
End if
End if
Print a + b + c
[Note- &&: Logical AND - The logical AND operator (&&)
returns the Boolean value true(or 1) if both operands are true
and return false (or 0) otherwise
||: Logical OR - The logical OR operator (||) returns the Boolean
value TRUE(or 1) if either or both operands is TRUE and
returns FALSE(or 0) otherwise
If(x) gets executed if the value inside if(), i.e., x is not zero]
(a) 8 (b) 14 (c) 16 (d) 29

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
124. What will be the output of the following pseudocode for
a = 6, b = 6?
Integer funn(Integer a, Integer b)
if(a > b + 1)
return 1
Else
return a + b + funn(a + 3, b – 1)
End if
End function funn()
(a) 9
(b) 13
(c) 15
(d) 25
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
125. What will be the output of the following pseudocode?
Integer a, b, c b=7

Set a = 5, b = 13, c = 2 c=8

if(1 > a OR 1 > b) End if

a=b Print a + b + c

if(b) (a) 42

b = 11 (b) 5

Else (c) 32

c = 11 (d) 24

End if
Else
a=9

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
126. What will be the output of the following pseudocode?
Integer a, b, c
Set a = 15, b = 71, c = 4
if(a > c + 100)
if(b > c)
c=b
b=a
a=c
End if
b=a
Else
a=c+b
End if
Print a + b + c
(a) 150 (b) 147 (c) 158 (d) 153

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
127.What will be the output of the following pseudocode for a = 2, b = 3?
Integer funn(Integer a, Integer b)
Integer c
for(each c from 1 to 3)
a=a+c
End for
if(a < b)
if(a > 2)
return a + b
Else
return b
End if
End if
return b + a
End function funn()
(a) 7 (b) 5 (c) 4 (d) 11

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
128. What will be the output of the following pseudocode?
String str1 = “AA”, str2 = “aa”
Print isPalin(reverse(lower(str1) + lower(str2)) +
reverse(upper(“aaa”)))
[Note: isPalin(string) returns 1 if the string is palindrame,
otherwise returns 0. Ex- isPalin(“yyy”) returns 1
lower(string) converts all the letters of the string to lower case.
Ex- lower(“OkaY”) would return “okay”
reverse(string) reverses the string. Ex- reverse(“okaY") returns
“Yako”]
(a) 0
(b) 3
(c) 1
(d) 2
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
129. What will be the output of the following pseudocode?
Integer a, b, c
Set a = 4, b = 4, c = 4
b=c–3
if (b > a)
b=b+a
Else
a=a+b–2
End if
Print a + b
(a) 15 (b) 1 (c) 9 (d) 4

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
130. What will be the output of the following pseudocode?
Integer p, q, r
Set p = 71, q = 11, r = 12
p = p + (p mod p)
r = r + (r mod r)
Print p + q + r
[Note- mod finds the remainder after the division of one
number by another. For example, the expression “5 mod 2”
would evaluate to 1 because 5 divided by 2 leaves a quotient of
2 and a remainder of 1.]
(a) 94
(b) 98
(c) 102
(d) 90
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
131. What will be the output of the following pseudocode?
Integer a, b, c, d
Set a = 1, b = 1
if(a + 1 > b)
for(each c from 1 to 2)
for(each d from 1 to 2)
a=a+1
Jump out of the loop
End for
Continue
a=a+1
End for
End if
Print b + a
[Note- Continue: When a continue statement is encountered inside a loop,
control jumps to the beginning of the loop for next iteration, skipping the
execution of statements inside the body of the loop for the current iteration]
(a) 2 (b) 8 (c) 3 (d) 4

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
132.Consider the below-given pseudocode.
Integer a, b, x
set a = 12, b = 25
x = a ………… b
print x
Which of the following operators is used between the operand a and
b such that the output would be 29?
[Note: & - Bitwise AND operator, it takes two numbers as operands
and does AND on every bit of two numbers. The result of AND is 1
only if both bits are 1
&&: Logical AND - The logical AND operator (&&) returns the
Boolean value true(or 1) if both operands are true and return false
(or 0) otherwise.
||: Logical OR - The logical OR operator (||) returns the Boolean value
TRUE(or 1) if either or both operands is TRUE and returns FALSE(OR
0) otherwise]
(a) &(Bitwise And)
(b) ||(Logical Or)
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
133. What will be the output of the following pseudocode for
a = 2, b = 3?
Integer funn(Integer a, Integer b)
if(a > 0 || b > 1)
return a + funn(a – 1, b – 2)
End if
if(a < b)
return b
End if
return a
End function funn()
(a) 3 (b) 5 (c) 21 (d) –11

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
134. What will be the output of the following pseudocode for
a = 2, b = 1?
Integer funn(Integer a, Integer b)
Integer c
for(each c from 1 to 3)
a=a+c
End for
if(a < b)
return a + b
End if
return a
End function funn()
(a) 8 (b) 4 (c) 7 (d) 3
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
135. What will be the output of the following pseudocode?
Integer a, b, c
Set a = 1, b = 4
for (each c from 6 to 7)
if(b – 4)
a=a+1
Else
Continue
a=a–2
End if
a=a+2
End for
Print b + a
[Note- Continue: When a continue statement is encountered inside a loop,
control jumps to the beginning of the loop for next iteration, skipping the
execution of statements inside the body of the loop for the current iteration]
(a) 8 (b) 5 (c) 2 (d) 9

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
136. What will be the output of the following pseudocode?
Integer p, q, r
Set p = 5, q = 13, r = 2
if(q > p || 1 > q)
p=q
Else
p=9
End if
Print p + q + r
(a) 46 (b) 35 (c) 16 (d) 28

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
137. What will be the output of the following pseudocode for a
= 1, b = 1?
Integer funn(Integer a, Integer b)
a=a+2
b=b+2
a=a+b
b=b+a
if(a)
a=1
Else
b=1
End if
return a + b
End function funn()
(a) 24 (b) 15 (c) 5 (d) 10
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
138. What will be the output of the following pseudocode?
Integer a[0], x, total
Set a[] = {3, 4, 5, 2}, total = 0
for(each x from 0 to 3)
total = total + a[x]
end for
print “The answer is”, total
(a) The answer is 12
(b) The answer is 17
(c) The answer is 120
(d) The answer is 14

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
139. What will be the output of the following pseudocode?
Integer a, b, c
Set a = 1, b = 4, c = 3
if(a && b)
a=a+a
if(a && b)
b=b+b
End if
End if
Print a + b + c
[Note- &&: Logical AND - The logical AND operator (&&) returns
the Boolean value true(or 1) if both operands are true and return
false (or 0) otherwise.
If(x) gets executed if the value inside if(), i.e., x is not zero.]
(a) 14 (b) 23 (c) 11 (d) 13
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
140.What will be the output of the following program?
class RecursiveFor{ System.out.println(“out =” + out);
public static void main(String[] args){ }
int out = 15; private static int main(int a,
for (int i = 4; i < 6; i++){ int b){

for (int j = 7; j >= 5; j--){ if (a – b ==0){

if (i == j) continue; return 2;

if (i > j){ }

out += main(i, j); return a + main(a – 1, b);

} }

else{ }

out += main(j, i); (a) out = 80

} (b) Goes into infinite loop

} (c) Compilation Error

} (d) out = 78
(e) out ©=2018
71SMART Training Resources Pvt. Ltd.
SMART TRAINING RESOURCES INDIA PVT. LTD.
141. Consider an empty queue, Q. The following operation are
performed on the queue:

1) Enqueue(1)

2) Enqueue(2)

3) Enqueue(3)

4) Enqueue(4)

5) Enqueue(5)

6) Enqueue(6)

7) Enqueue(7)

8) Dequeue(a)

8) Dequeue(b)

What is the value of b?

(a) 1 (b) 4 (c) 2 (d) 3


SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
142. GIVEN A PROBLEM, PARTIALLY CORRECT PROGRAM
AND SET OF INPUTS, MARK THE INPUT FOR WHICH THE
PROGRAM WILL NOT FUNCTION AS EXPECTED IN THE
PROBLEM.
#include<stdio.h>
#include<string.h>
int main()
{
char s1[1000];
gets(s1);
if((strcmp(s1,“sunny”)==0)||(strcmp(s1,”SUNNY”)==0))
printf(“Yes 1 can drive :)”);
else if((strcmp(s1,”rainy”)==0)||(strcmp(s1,”RAINY”)==0))
printf(“No
SMART I cant
TRAINING drive
RESOURCES :(“);
INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
else if((strcmp(s1,”foggy”)==0||(strcmp(s1,”FOGGY”)==0))
print(“Sorry invalid input :|”);
else
printf(“Sorry invalid input :|”);
return 0;
}
(a) RAINY
(b) FOGGY
(c) RAINYY
(d) MISTY

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
143. Petrol Variety
Dr. Dexter is now in the gas bunk. He has perfectly planned his trip. He has
been working keenly on the budget so that the trip goes on well. Now, he
finds that there are two varieties of fuel - Ordinary and Speed. Speed fuel
yields him a fairly better performance than its ordinary counterpart. He
wants Xinyou to find out as to which variety of fuel he must opt for to stick
to the budget.
Write a C program to find out the variety of fuel.
Input and Output Format:
Input consists of 5 lines.
The first line of input is a floating point number ‘m’ corresponding to the
mileage Dr. Dexter’s car yields.
The second line and third lines of input consists of floating point numbers
‘o’ and ‘s’ corresponding to the costs of ordinary fuel and speed fuel
respectively.
The fourth line of input is an integer ‘d’ corresponding to the distance
between the bunk and Shinyao.
The fifth line of input is a floating point number ‘b’ corresponding to the
budget for the fuel.
SMART TRAINING © 2018 SMART Training Resources Pvt. Ltd.
Output consistsRESOURCES INDIA
of a string PVT. LTD.or ‘Speed’.
‘Ordinary’
144. Weather Check
Xinyou has an inbuilt GPS system that gives its current position
coordinates as input. Using these coordinates Xinyou gets the
current weather information. Initially. Dr. Dexter wants Xinyou to
drive only when it is sunny. The different weather conditions are
‘sunny’, ‘rainy’, ‘foggy’.
Given a whether condition check whether Xinyou can drive or not.
Input Output Format:
Input consists of a string, corresponding to the weather condition.
Output is a string “Yes I can drive :)” or “SorryOutput
Sample invalid 2:
input :|” or
“No I cant drive :(”.
Sorry Invalid input :|
Sample Input 1:
Sample Input 3:
Sunny
rainy
Sample Output 1:
Sample Output 3:
Yes I can drive :)
No I can drive :(
Sample Input 2:
mistyTRAINING RESOURCES INDIA PVT. LTD.
SMART © 2018 SMART Training Resources Pvt. Ltd.
145. public class Test {
public void main(String[] args){
System.out.println(“Hello” + args[0]);}
}
What will be the output of the program, if this code is executed
with the command line:
java Test world
(a) Hello world
(b) The code does not run
(c) Hello
(d) Hello Test

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
146. What will be the output out of the program given
below?
#include <iostream>
using namespace std;
class M;
class N;
{
int p;
public:
N (int i)
{
p = ++I;
cout << p << “ “;
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
}
friend void f(N, M);
};
Class M
{

int p;
public:
M (int i)
{
p = p + i;
cout << p << “ “;

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
}
};
void f (N b, M a)
{
{
int g;
g = b.p + 4;
cout << g – 1;
}
};
int main()
{

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
M jj (4 + 1);
N j1 (2 * 3);
f (j1, jj);
return 0;
}
(a) 22 6 9
(b) 20 7 10
(c) 22 7 9
(d) 23 7 10

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
147. What will be the result of the below given code
snippet?
#include <stdio.h>
int main(int *A)
{
int M = 9;
A = &M;
*A = (M – 1);
printf(“%d”, ++*A++);
return 0;
}
(a) 0 (b) Compile time error
(c) 9 (d) Garbage value
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
148. What will be the output of the program given below?
#include <stdio.h>
#define sizeof(int) 3
#define float int
int main()
{
float a;
if(a = sizeof (int) / sizeof (float) }
if(a == 1.000000)
printf (“Testing”);
printf (“OK”);
return 0;
}
(a) Testing (b) OK (c) OKTesting (d)
TestingOK
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
149. How many elements of array ‘arr’ will get modified by the
function given below for n = 5 and arr[] = {3, 4, 6, 7, 2}?

Modify(arr, n)

Initialize var, i

Set var = n % 3

Set i = n

Repeat step 5 to 6 till i > 0

arr[i] = 5 – arr[var] + 2 * arr[i]

i = i – var

(a) 4

(b) 0

(c) 3

(d) 2
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
150. Distance & Speed Check - II

Xinyou now has been trained to drive. Dr. Dexter wants to get to a
national conference to present Xinyou. The venue of the
conference is x kms away from his workshop. He wants to know if
Xinyou will be able to make it to the conference in ‘h’ hours driving
within the city speed limit ‘s’.

Write a C program module that checks if he will be able to make it


to the conference on time.

Input and Output Format:

Input consists of 3 lines.

The first line of input is a floating point number corresponding to


the distance ‘d’ 0 < d < 32767

The second line of input is a floating point number corresponding


to the speed limit ‘s’, 0 < s < 32767

The third line of input is a floating point number corresponding to


the time
SMART ‘h’, 0RESOURCES
TRAINING < s < 32767
INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
Output consists of a single string ‘Yes’, ‘No’ or ‘Invalid Input’.
Sample Input 1:
100
25
5
Sample Output 1:
Yes
Sample Input 2:
150
–50
123
Sample Output 2:
Invalid Input
Sample Input 3:
100

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
151.Concatenate characters
You are given N characters in a line.
Join all the characters and print them in a single line.
Input format
 The first line contains an integer N.
 The second line contains N characters.
Output format
Join all the characters and print them in a single line.
Constraints
1 ≤ N ≤ 10
Sample input 1
4
omar
Sample output 1
omar
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
152.Petrol Bunks
Dr. Dexter has now started his trip to Shinyao. Unfortunately, he has
forgotten about the fuel. There are two gas bunks on the way to
Shinyao, ‘A’ and ‘B’. As soon as his car reaches bunk A it runs out of
fuel. Banks A and B are ‘d’ miles apart. Xinyou, the robot finds out from
statistics that one of the bunks provides the best quality fuel. They
decide on filling the best quality fuel.
Write a C program module that finds the quantity of fuel that has no
filled at bunks A and B.
Input and Output Format:
Input consists of 4 lines.
The first line of input is an integer ‘d’ corresponding to the distance
between bunks A and B
The second line of input is an integer ‘s’ corresponding to the distance
between bunk A and Shinyao.
The third line of input is a floating point number ‘m’ corresponding to
the mileage Dr. Dexter’s car yields
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
The fourth line of input is an character ‘b’ corresponding to the bunk
that provides the best quality fuel.
Output consists of the quantities of fuel to be filled at bunks A and B,
correct upto 2 decimal places.
O < d <= 5 < 32767
b takes values ‘A’ or ‘B’
Assume that bunk A lies before bunk B.
Sample Input 1:
100
200

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
153.What does the following piece of code do BST? struct tree *fun2(struct
tree *t)

if(t! = NULL)

while(t -> rchild! = NULL)

t = t -> rchild;

return t;

(a) To find the maximum element

(b) To find the minimum element

(c) Both

(d) None
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
154. What will be the Output?
#include<stdio.h>
int main()
{
if(1 || 0)
printf(“Dennis Ritchie is Father of C Programming”);
else
printf(“Why to learn C?”);
return 0;
}
(a) Why to learn C? (b) Run time
Error
(c) Dennis Ritchie is Father of C Programming (d) Compile
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
155.Speed Lanes

Dr. Dexter plans a trip to Shinyao, a famous tourist spot. Now Xinyou
has to decide on which lane he has to take to goto Shinyao. There are
‘n’ lanes each with a speed limit ‘si’ kmph. If Xinyou has to reach
Shinyao within ‘h’ hours. Choose the safest lane he must take.

Write a C programming module that displays the route Xinyou has to


take.

Input and Output Format:

Input consists of n + 3 lines.

The first line of input is an integer ‘n’ corresponding to the number of


lanes. 0 < n < 32767

The next n lines consist of floating point numbers ‘si’ each


corresponding to the speed limit of the i th lane.

The next line of input corresponds to ‘d’ the distance to be travelled.

The last line of input corresponds to ‘t’ the time in hrs within which
Xinyou has to reach Shinyou.
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
0 < n, si, d, t < 32767

Output consists of an integer corresponding to the lane number. Print –


1 if no lane can be taken.

Assume that lanes are numbered from 1 to n.

Sample Input 1:

30.00

60.00

90.00

80

Sample Output 1:

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
156. A function void check(int *num1, int*num2) is called
from main() function as below
int a = 6, b = 5;
check(&a, &b);
printf(“%d %d”, a, b);
The body of the function is written below
int temp = *num1; *num1 = *num2; *num2 = temp;
What is the value of a and b displayed in main() function after
the function call?
(a) 6 6
(b) 6 5
(c) 5 6
(d) 5 5
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
157.Color Detection
Dr. Dexter is a Robotics Research Scientist. He is now on the urge of
building his own humanoid robot – Xinyou.
Xinyou has an in built color sensor. The sensor senses the environment
and gives the the color that is highly present in the spectrum. Now, Dr.
Dexter wants Xinyou to output whether it is dawn or dusk based on the
sensor’s output. The sensor output ‘BLUE’ or ‘RED’. If color blue is
scattered more it is Dawn and if red is scattered more it is Dusk.
Any input other than ‘BLUE’ and ‘RED’ is assumed to be an invalid
input.
Write a C program that finds out whether it is Dawn or Dusk.
Input Output Format:
Input is a string.
Output is a string, either “It is dawn”, “It is dusk”, or “Invalid Input”.
Sample Input 1:
BLUE
Sample Output 1:
It is dawn
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
158. The following function reverse() is supposed to reverse
singly linked list.
There is one line missing at the end of the function.
static void reverse(struct node** head_ref)
}
{ What should be added in
struct node* prev = NULL; place of “/*ADD A
struct node* current = *head_ref; STATEMENT HERE*/”, so
struct node* next; that the function correctly
reverses a linked list.
while (current! = NULL)
(a) *head_ref = current;
{
(b) *head_ref = next;
next = current -> next;
(c) *head_ref = prev;
current -> next = prev;
(d) *head_ref = NULL;
prev = current;
current = next;
}
/*ADD A STATEMENT HERE*/
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
159. What will be the output of following program?
#include<stdio.h>
int main()
{
int a = 10;
switch(a){
case 5 + 5:
printf(“Hello\n”);
default:
printf(“OK\n”);
}
return 0;
}
(a) Hello (b) OK (c) Hello OK (d) Error

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
160. After the following code:
int *p;
int i;
int k;
i = 63;
k = i;
p = &i;
Which of the following statements will change the value of i to
2105?
(a) *k = 2105
(b) k = 2105
(c) p = 2105
(d) *p = 2105
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
161. What will be the output of the following pseudocode?
Integer a, b, c
Set a = 1, b = 1
if(a – b || 0)
for (each c from 1 to 3)
a=a+1
if(a)
Jump out of the loop
End if
End for
Else
for (each c from 1 to 4)

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
a=a–1
if(a)
Jump out of the loop
End if
End for
End if
a=a+b
Print b + a
[Note: If(x) gets executed if the value inside if(), i.e., x is not
zero
||: Logical OR - The logical OR operator (||) returns the boolean
value TRUE(or 1) if either or both operands is TRUE and
returns FALSE(OR 0) otherwise]
(a) 8 (b)1 (c) 5 (d)4
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
162. What will be the output of the following pseudocode?
String str=”News”, str2=”Yorks”
Print countVowel(subString(str1, 0, 1) + subString(str2, 1, 3))
[Note: countVowel(string) returns the number of vowels in the
string. Ex- countVowel(“okay”) return 2
subString(string, integer-1, integer-2) returns a substring from
index equals integer-1 to index equals integer-2. Ex-
subString(“OkaY, 0, 2”) would return “Ok”)
(a) 4
(b) 1
(c) 0
(d) 8

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
163. What will be the output of the following pseudocode?
String str1=”Nesting”, str2=”Western”
Print isPalin(subString(str1, 1, 3) + reverse(subString(str2, 1,
3)))
[Note: subString(string, integer-1, integer-2) returns a
substring from index equals integer-1 to index equals integer-
2. Ex- subString(“OkaY”, 0, 2) would return “Ok”.
reverse(string) reverses the string. Ex- reverse(“okaY") returns
“Yako”.
isPalin(string) returns 1 if the string is a palindrome, otherwise
returns 0. Ex- isPalin(“yyy”) returns 1.]
(a) 10
(b) –4
(c) 1
SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
164.Analyse the given program and answer the following question.

int main() j--;

{ }

int i, j, k; print(“%d, %d, %d”, i, j, k);

for(i = 5; i <= 9; i++) return 0;

{ }

for(j = –6; j <= –2; j++) What would be the printed


values of the variables “j” and
{
“k” in the above program?
for(k = 1; k <= i; k++)
(a) –1 and 10
{
(b) –1 and 11
k++;
(c) –1 and 12
}
(d) –2 and 10
}

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
165. What would be the two values of k that are printed by
the following pseudocode?
Integer a, b, k
set a = 34, b = 12
k = (a / b) & (b / a)
print k
k=k/a+k/b+1
print k
[Note: & - Bitwise AND operator, it takes two numbers as
operands and does AND on every bit of two numbers. The
result of AND is 1 only if both bits are 1]
(a) 0 0 (b) 1 1 (c) 0 1 (d) 1 0

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.
Thank You …

SMART TRAINING RESOURCES INDIA PVT. LTD. © 2018 SMART Training Resources Pvt. Ltd.

You might also like