You are on page 1of 9

CSE1011: Fundamentals of Computer Science

(FoCS)

L-04: PseudoCode

Dr. Sanjeev Kumar Dwivedi


EMP ID: 70605
VIT-AP School of Computer Science and Engineering (SCOPE)
VIT-AP University
Definition of PseudoCode:
• Pseudo code is one of the tools that can be used to write a preliminary plan that can
be developed into a computer program.

• Pseudo code is a generic way of describing an algorithm without the use of any
specific programming language syntax.

• It is, as the name suggests, pseudo code —it cannot be executed on a real computer,
but it models and resembles actual programming code, and is written at roughly the
same level of detail.

• Pseudo code, by nature, exists in various forms, although most borrow syntax from
popular programming languages (like C programming language).

• Natural language is used whenever details are unimportant. 2


• Pseudocode is an intermediate state between algorithm and program that plays
supports the transition of the algorithm into the program.

• Use of standard programming structures such as if, if-else, for, while, and cases for
writing the pseudocodes.

3
Pseudocode for addition of two integer numbers:

1. ADD(num1, num2, Sum)


2. Begin
3. WRITE “Please enter two numbers to add”
4. READ num1
5. READ num2
6. Sum = num1+num2
7. WRITE Sum
8. End

4
Pseudocode to check whether the number is Odd or Even:

1. Even_Odd(number)
2. Begin
3. DISPLAY "Enter the Number - "
4. READ number
5. IF (number MOD 2 == 0) THEN
DISPLAY "Number is Even"
ELSE
DISPLAY "Number is Odd"
END IF
6. End

5
Pseudocode for sum and average of three numbers:

1. Sum_Average(num1, num2, num3, Sum, Average)


2. Begin
3. WRITE “Please enter the numbers ”
4. READ num1
5. READ num2
6. READ num3
7. Sum = num1+num2+num3
8. Average = Sum/3
9. WRITE Sum, Average
6. End

6
Pseudocode for print the numbers from 1 to N:
1. Display(num1, num2)
2. Begin
3. Set num1=0
3. WRITE “Please enter the value of num2”
4. READ num2
5. Begin FOR()
6. IF (num1 < num2) THEN
num1= num1 + 1
DISPLAY “num1“
ELSE
Terminate
END IF
7. END FOR()
8. End 7
Q1. Write a pseudocode to check the largest number between the
two numbers?

Q2. Write a pseudocode to check the largest number between the


three numbers?

Q3. Write a pseudocode to sum and average of “N” numbers?

8
Thank You

You might also like