What is Pseudo Code?

What is Pseudo Code

Here on this page, we will learn What is meant by the commonly used term What is Pseudo Code in Programming and also learn how to write Pseudo Codes.

What is Pseudo Code

Pseudo Code

  • Definition: It is an informal way of programming that does not require any strict programming language syntax.
  • Usage: It is used for creating a rough draft/outline of a program.

Pseudocode means “false code” (fake code) which doesn’t require semi-colons, and curly braces any strict syntax.

Let’s understand it better

Example ( Real Life) :

Pseudo Code is like a recipe, coding is like cooking and output is the cooked food.

The recipe is a rough draft of what will be the output (food). You don’t need to follow recipes all the time or write recipes all the time before cooking but if you follow recipes there are more chances of getting the desired outcome. If you don’t use a recipe and the outcome is not what you expected you’ll again have to start from scratch which will waste time as well as resources.

Similarly, It is Pseudo Code is a rough draft of what you need to do for your desired output.

Benefits :

  • Programming Language Independent: There are many languages available to code if you share your code with someone there are chances he/she doesn’t know that language and is unable to understand but as Pseudo Code is Programming language-independent one can understand and implement in their Programming language.
  • Time and Resource-saving: As we are keeping Pseudo Code simple and rough without any Programming syntax It is easy to write it again if the desired outcome is not archived.

Pseudo Code questions are commonly asked in the placement drive of Capgemini, Accenture, Infosys, Mu Sigma, and many more.

Sample Questions

Question 1

Run

#include<stdio.h>
int main()
{
    for (int x = 10; x >= 0; x--) {
        int z = x & (x >> 1);
        if (z)
            printf("%d ", x);
     }
    
}

Solution

7 6 3

Question 2

Run

#include<stdio.h>
int main()
{
    int a = 100;
    printf("%0 %x", a);
}

Solution

%x

Question 3

Run

#include<stdio.h>
int main() 
{
    typedef int num;
    num bunk = 0.00;    
    printf("%d", bunk);
    return 0;
    
}

Solution

0

Question 4

Run

#include<stdio.h>
int main ()
{
  char c,a,b;
  c='f';
  a='s';
  b='x';
  int sum= c+a+b;
  printf ("%d", sum);
}

Solution

337

Question 5

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

Solution

3125

Question 6

initialize char c
set c= a
print "%d",a

Solution

97

Question 7

int sum (int B[], int n)

{

  int s = 0, j;

  for (j = 0; j < n; j++)

    s = s + B[i];

  return s;

}// sizeof(int) = 2 bytes

Solution

2n + 8

Question 8

For input e = 7 & f = 8.

  work (input e, input f)

  If (e < f)

  return work (f, e)

  elseif (f != 0)

  return (e + work (e, f - 1))

  else

  return 0

Solution

56

Question 9

Input p = 9, w = 6 ,

p = p + 1 ;

w = w - 1 ;

p = p + w 

if (p > w)

  print p

else

  print w

Solution

15