# Infosys System Engineer Pseudo Code Questions and Answers

Infosys System Engineer Pseudo Code Questions and Solutions are available below on this page. Pseudo Code is a normal representation of algorithm code in C, C++, or any other language. In the Pseudo Code round, there will be a total of 5 questions that we need to answer within 10 minutes.

The Difficulty level of the paper goes from Moderate to High. Pseudo-Code are not machine-readable codes it is just as same as algorithms written in coding format. Infosys has added a new Pseudo Code section in its selection process. This update is done by Infosys for their selection process.

Many of the websites still have the old syllabus, so please be careful while referring to them. This section will have 5 questions that you have to solve in 10 minutes.

Company - Infosys

Total Time Duration - 10 minutes

Number of Questions - 5 Ques

Negative Marking -  No

Question 1: Predict the output of the given pseudo code if the value of n is 35:

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

Question 2: What will be the output of the given pseudo code if n = 10?

Initialize i to 5

while i < n do

increase sum by i

increment i

end while

Write sum

Options

a : 25.0

b : 35.0

c : 55.0

d : 45.0

Question 3: Predict the output of the given pseudo code if the value of a number is 6:

k = 2

i = 2

while i<=number

k = k * i

i = i +1

end while

write k

Options

a : 1700.0

b : 1560.0

c : 1440.0

d : 1340.0

Question 4: What will be the number of " * " printed by the given pseudocode when input is 25?

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

Options

a : 55.0

b : 45.0

c : 25.0

d : 35.0

Question 5: You have written the pseudo-code given alongside for performing a binary search in an array of elements sorted in ascending order. Which step is 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

Options

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

1. What is the output?

#include<stdio.h>

int main()

{

for (int x = 10; x >= 0; x--) {

int z = x & (x >> 1);

if (z)

printf("%d ", x);

}

}

Explanation: Here, in the given code, >> is the bitwise right shift operator and x>>y => x/(2^y) and & is the bitwise and operator and gives 1 only if both bits are same. Now, for x = 10, (10>=0) z = 10 & (10>>1) => z = 10 & 5 => z=10. Similarly for x= 9, 8, 5, 4, 2, 1 and 0 , z will be zero and for x=7, z will be 3 , for x= 6, z will be 2 and for x=3, z will be 1 for x=7, 6, and 3 z is non zero so the will get printed on the output screen. Hence, we get output as 7 6 3

2. What is the output?

#include<stdio.h>

int main()

{

int a = 100;

printf("%0 %x", a);

}

Explanation: In this question %0 will cancel out the a, while %x will get printed

but,

if we only write printf("%x"); without passing any parameter for x,

it will show an error.

3. What is the output?

#include<stdio.h>

int main()

{

typedef int num;

num bunk = 0.00;

printf("%d", bunk);

return 0;

}

Explanation: The integer part of 0.00 is equal to 0.

Hence only zero will be printed with print("%d", bunk) when 0.00 is passed because %d stands for integer.

4. 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;

}

Explanation:

sizeof(x), that is float, is 4

sizeof(y), that is long int, is 8

sizeof(x+y) that also comes out to be float will have size = 4

here it is asking sizeof(y) == sizeof(x+y)

i.e 8 == 4

"==" operator gives a result in either 0 or 1

5. What is the output?

#include<stdio.h>

int main()

{

int any = ' ' * 10;

printf("%d", any);

return 0;

}

Explanation:

Ascii value of space (' ') is 32 and 32 * 10 is 320

6. 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;

}

Explanation: In C when you divide the integer with a float without the typecasting it gives a "Floating Point Exception" error

8. 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);

}

Explanation

Iteration 1 : rem = 3(987 % 4), num = 98

Iteration 2 : rem = 2(98 % 4), num = 9

Iteration 3 : rem = 1(9 % 4), num = 0

9. What will be the output of the following Pseudo Code.

#include<stdio.h>

int main()

{

float i;

i = 1;

printf("%d",i);

return 0;

}

Explanation

If float variable is declared as an integer type

then, it will always give garbage value.

10. What will be the output of the following pseudocode:

public class Main

{

public static void main(String[] args)

{

String names[] = new String;

for(int x=0; x<args.length; x++)

names[x] = args[x];

System.out.println(names);

}

}

Explanation:

value of args.length is 0

So, the loop will not run either of the time

Hence, null will be printed.