Pseudo Code

A Pseudo Code is an informal way of writing the steps that should be followed for writing a program for human understanding. It should be just written in the English language to make the complex program easy to understand.

For graphical representation, we use the alternative of pseudo-code which is Flow Charts.

An algorithm for the factorial of a given number:

  1. Start
  2. Initialize fact = 1
  3. Input the value of n from the user
  4. For i = 0 to i <= n repeat the process
  5. fact = fact * i
  6. i++ (increment i by one)
  7. print the fact value
  8. stop

Now its pseudo code will be:

  • Start the program
  • Declare variables fact and n 
  • Enter the number for n 
  • for i=1 to i <=n 
  • Perform fact = fact * i
  • Output fact
  • End the program

By using the above pseudo-code, creating a program for the factorial of a given number using for loop:

#include <stdio.h>

void main() {
  int n, fact=1,i;
  printf("enter value for n");
  scanf("%d",&n);
  for(i=1; i<=n; i++) {
    fact=fact*i;
  }
  printf("\n factorial of %d is %d", n, fact);
}

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top