0% found this document useful (0 votes)
19 views4 pages

Itc Lab Flowvchart

Uploaded by

tiktokfun86
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views4 pages

Itc Lab Flowvchart

Uploaded by

tiktokfun86
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ITC – Lab

Objective
To make students familiarize with nature of problem and its best possible solutions and then the most
efficient possible solutions.

Outcomes
Students will be able to identify the nature of problem and its solutions.

Content

Flowchart and Pseudo Code:

Introduction to Algorithms and Pseudocode

In computer science, an algorithm is a well-defined sequence of steps or instructions


designed to solve a specific problem or perform a particular task. Algorithms form the
foundation of programming, providing a clear blueprint for how a task should be
completed. An effective algorithm breaks down complex problems into simpler, logical
steps that are easy to understand and implement. Algorithms are fundamental in many
domains, from sorting and searching data to controlling devices, automating processes, and
making decisions.

1
To create an algorithm, we must:

1. Understand the problem requirements.


2. Identify the input and expected output.
3. Outline a step-by-step plan that transforms the input into the desired output.

An algorithm is often represented in pseudocode for clarity before being converted into a
specific programming language. Pseudocode provides a language-independent way to
describe an algorithm's logic, using human-readable terms and standard programming
constructs like conditional statements and sequential steps. It focuses on the overall
structure of the solution without worrying about specific syntax.

Key Elements of an Algorithm

1. Input: The data or values required to solve the problem.


2. Process: The logical steps needed to transform the input into the output.
3. Output: The result or outcome after executing the algorithm.

Example Algorithm and Pseudocode

Let’s consider a simple example where we want to check if a given number is positive,
negative, or zero.

Algorithm

1. Take a number as input from the user.


2. Check the number:
a. If the number is greater than zero, it is positive.
b. If the number is less than zero, it is negative.
c. If the number is zero, it is neither positive nor negative.
3. Display the appropriate message based on the number's value.

Pseudocode

START
Prompt the user to enter a number
Input number
IF number > 0 THEN
Output "The number is positive"
ELSE IF number < 0 THEN
Output "The number is negative"
ELSE
Output "The number is zero"
END

2
There are three common ways to represent an algorithm:

1. Natural Language: Describes the steps of the algorithm in simple, human-readable


text.
a. Example: "First, ask the user for a number. Then, check if the number is
positive or negative and display the result."
2. Flowchart: Represents the algorithm visually using symbols like rectangles,
diamonds, and arrows to indicate the flow of control.
a. Example: Start → Input Number → Decision (Positive/Negative) → Output
→ End.
3. Pseudocode: Uses a structured, language-independent style to outline the algorithm
with statements resembling programming code.
a. Example:
START
Input number
IF number > 0 THEN
Output "Positive"
ELSE
Output "Negative"
END
Task 01:

Design a flowchart and write pseudocode for organizing a library book borrowing process:

1. Start by asking the user for the book title they want to borrow.
2. Check if the book is available.
3. If the book is available, record the borrower’s name and due date for return.
4. Mark the book as borrowed and display "Borrowing successful."
5. If the book is not available, display "Book is currently unavailable."
Task 02:

Design a flowchart and write pseudocode to check attendance eligibility for a student to take
an exam:

1. Ask the student for the total number of classes held.


2. Ask the student for the number of classes attended.
3. Calculate the attendance percentage.
4. If attendance is 75% or higher, display "Eligible for Exam."
5. If attendance is below 75%, display "Not eligible for Exam."

3
Task 03: Create a flowchart and write pseudocode for a program that takes three integers as
input and finds the largest number among them.

• Inputs: Three integers (num1, num2, num3)


• Output: Display the largest number.

Task 04: Create a flowchart and write pseudocode for a program that checks if a given year
is a leap year.

• Input: An integer representing the year.


• Output: Print whether the year is a "Leap Year" or "Not a Leap Year."

Task 05: Create a flowchart and write pseudocode for a program that calculates the
factorial of a given number.

• Input: A positive integer n.


• Output: Display the factorial of n (i.e., n!).

Task 06: Create a flowchart and write pseudocode for a program that checks if a given
number is prime.

• Input: A positive integer num.


• Output: Display whether the number is "Prime" or "Not Prime."

Task 07: Create a flowchart and write pseudocode for a program that calculates the simple
interest based on the principal amount, interest rate, and time period.

• Input: Principal amount (principal), interest rate (rate), and time period (time in
years).
• Output: Display the calculated simple interest.

You might also like