Today we’ll discuss Pseudo Code Questions as well as Infosys Pseudo Code Questions with answers, But before discussing the questions we will make you know about the Pseudo Code.
Table of Contents
What is Pseudo Code?
The Pseudo codes are used to represent the algorithm with the help of any programming language. They are not machine-readable codes and they are the same as algorithms written in the coding format.
Pseudo Code Questions are a simple way to write programming code in English. Pseudo-code is an informal writing style for the program algorithm independent from programming languages to show the basic concept behind the code. It is also an informal language that helps developers to develop the algorithms.
Pseudocode is not an actual programming language. So it cannot be compiled and not be converted into an executable program. It uses short or simple English language syntax to write code for programs before it is converted into a specific programming language. It is also useful in a program development process and the programmer will ensure that actual programming is likely to match design specifications.
Pseudo Code Questions
Infosys conducts an online exam each and every year and the pseudo-code is the 4th round conducted. The students who are able to clear the Pseudo Code round are only eligible for the next round i.e Puzzle Solving. This is the most important section to crack the Infosys online test. Generally, a total of 5 questions are asked which you’ve to solve within a time period of 10 minutes. These 5 questions will decide whether you’ll get selected or not.
These 5 questions are based on C, C++, and the Data Structures. The difficulty level of these questions is from moderate to high. If you practice more and more pseudo-code questions then you’ll be able to crack this section easily.
Note: There is no negative marking in this section.
Infosys Pseudo Code Questions Pattern
Topics | No of Questions | Difficulty Level |
---|---|---|
C language | 1 | Medium |
C++ language | 1 | Medium |
Data Structures | 2 | Medium |
Pseudo Code Questions With Answers
So let’s see Infosys pseudo code questions that are asked in their Pseudocode sections. If you solve the below questions then you might be able to solve the questions in the upcoming exams. So, become an ace by solving more and more questions till you become confident in solving the questions on your own.
Q.1 What will be the output of the following code?
//Learnprogramo - programming made simple #include<stdio.h> int main() { int a = 100; printf("%0 %x", a); }
- 100
- %a
- %x
- None
Ans: Option 3.
Explanation: In the above question %x will be get printed as %a cancel out a. If we write only printf(“%x”); with no parameters for the x then it’ll show the error. So option 3 is correct.
Output:
Q.2 Predict the Output for the following code?
//Learnprogramo - programming made simple #include<stdio.h> int main() { typedef int num; num bunk = 0.00; printf("%d", bunk); return 0; }
- 0.0
- 0
- logical Error
- None
Ans: Option 2.
Explanation: In C, the integer part of 0.00 is always equal to 0. Therefore only 0 will be printed from printf(“%d, bunk) because in C, %d stands for an integer.
Output:
Q.3 What will be the output of the following code?
//Learnprogramo - programming made simple #include<stdio.h> int main() { int x; for (x = 10; x >= 0; x--) { int z = x & (x >> 1); if (z) printf("%d ", x); } }
- 763
- 7 6 3
- 678
- 6 7 8
Ans: Option 2.
Explanation: In the above program ‘>>’ is called a bitwise right shift operator in C and ‘&’ is called a bitwise AND operator. The & operator will give 1 only if the Left and the Right bits are the same. Here, for x=10, (10>=0) z=10 & (10>>1) =>z=10 & 5=>z=10 and similarly for x = 9, 8, 5, 4, 2, 1 and 0 the value of z will be the zero. Similarly for x = 7, the value of z will be 3, for x = 6 will be 2 and for the x = 3, the value will be 1. The value of z will be 1 for the x = 7, 6, and 3 where z is a non-zero. Therefore the values 7, 6, and 3 will get printed on the screen.
Output:
Q.4 Predict the output of the following code?
//Learnprogramo - programming made simple #include<stdio.h> int main() { float x = 0.0; long int y = 10; printf("%d", sizeof(y) == sizeof(x+y)); return 0; }
- 1
- 2
- 3
- 5
Ans: Option 1.
Explanation: In C language, the size of variable x which is of type float is 4, and the size of variable y which is long int is 8. So after combining both (x + y) the size comes out as float which is 4. In the above question, its asking sizeof(y) == sizeof(x+y) i.e 4 == 4. The operator “==” return either 1 or 0 therefore the answer is 1.
Output:
Q.5 What will be the output of the following code?
//Learnprogramo - programming made simple #include<stdio.h> int main() { int any = ' ' * 10; printf("%d", any); return 0; }
- 340
- 320
- 300
- 360
Ans: Option 2.
Explanation: The ASCII value of the space (‘ ‘) is 32. Therefore ‘ ‘ * 10 = 32 * 10 = 320.
Output:
Q.6 Predict the output of the following code?
//Learnprogramo - programming made simple #include<stdio.h> int main() { int go = 5.0, num = 1*10; do { num /= go; } while(go--); printf ("%d\n", num); return 0; }
- Compilation Error
- None
- 5 10 15
- Floating Pointer Exception
Ans: Option 4.
Explanation: In the C language, if you divide an integer with a float without any typecasting then it will throw a “Floating Point Exception” error.
Q.7 What will be the output of the following Pseudo Code?
//Learnprogramo - programming made simple #include <stdio.h> int main() { int num = 987; int rem; while(num!=0) { rem = num % 4; num = num / 10; } printf("%d",rem); }
- 5
- 1
- 0
- 10
Ans: Option 2.
Explanation: In the first iteration, rem = 3(987 % 4), num = 98, In second Iteration, rem = 2(98 % 4), num = 9. Similarly in the third Iteration, rem = 1(9 % 4), num = 1.
Output:
Q.8 Predict the output of the following pseudo-code?
//Learnprogramo - programming made simple #include<stdio.h> int main() { float i; i = 1; printf("%d",i); return 0; }
- 1.000000
- 1
- Error
- Garbage Value
Ans: Option 4.
Explanation: In C language, if the float variable is declared as an integer type then, the program will always return a garbage value.
Q.9 What will be the output of the following Java Pseudo Code?
//Learnprogramo - programming made simple 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]); } }
- Null
- Name
- Exception
- Compilation Error
Ans: Option 1.
Explanation: Here, the value of args.length is 0. Therefore, the loop will not either run the time. So, the null will get printed.
Output:
Q.10 What will happen when the following program is executed?
#Learnprogramo - programming made simple Set Integer res=0do --res display res res++ while(res>=0) end do-while
- The code will run an infinite number of times.
- The compiler will not enter inside the loop.
- The value of res will be displayed twice.
- A program will compile and the value of res will be displayed once.
Ans: Option 1.
Frequently Asked Questions (FAQ)
Q.1 What is Pseudo Code?
Ans: The Pseudo codes are used to represent the algorithm with the help of any programming language. They are not machine-readable codes and they are the same as algorithms written in the coding format.
Q.2 What is Infosys Pseudo Code Test?
Ans: This is the 4th section of the Infosys online test. If you clear this section then only you’ll be eligible for the next section.
Q.3 In how much time do we’ve to solve the questions?
Ans: You’ve to solve a total of 5 questions in a time period of only 10 minutes.
Q.4 Pseudo Codes are mainly written in which programming language?
Ans: The pseudo-codes are language-free representations of an algorithm. So, it’s not a complete representation of any specific programming language.
Q.5 What is the difficulty level of Infosys Pseudo Code Questions?
Ans: The questions asked are of medium to the high difficulty level. If you practice more and more questions then it’ll be easy for you.
Conclusion
So, in this way we’ve solved the Infosys Pseudo Code Questions with Answers. If you’ve any doubts then, please feel free to contact us. We’ll reach you as soon as possible.
Thanks and Happy Coding :)
Also Read:
- Amcat Coding Questions.
- Mindtree Coding Questions.
- Cocubes Test.
- TCS Codevita.
- Zoho Aptitude Questions.
- Wipro Coding Questions.
- Hexaware Interview Questions.
- Capgemini Exam Pattern.
- Accenture Coding Questions.
- Cognizant Coding Questions.