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);
}

No Comments

Send Comment Edit Comment


|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
Previous
Next