0% found this document useful (0 votes)
2 views6 pages

Analysis Chart, Algorithm, Flowchart

UNIT 1

Uploaded by

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

Analysis Chart, Algorithm, Flowchart

UNIT 1

Uploaded by

balakumaran
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

📘 Problem Analysis Chart in C

Programming
1. What is a Problem Analysis Chart?
A Problem Analysis Chart (PAC) is a simple tool used before writing a program. It helps in
breaking down a problem into Input, Process, and Output (IPO).

This chart ensures that the problem is well understood and avoids confusion before coding.

2. Structure of a Problem Analysis Chart


Input (What data we Output (What result we
Process (Steps / operations)
need) get)
Data or values entered by Logical operations performed Final result displayed to
the user on input the user

3. Example: Find the Sum of Two Numbers


Problem Analysis Chart

Input Process Output


Two numbers: a, Add the numbers: Display
b sum=a+b sum

4. Explanation in Brief
Input: The program needs two numbers (provided by the user).
Process: The program will add the two numbers using the arithmetic + operator.
Output: The result (sum) will be displayed on the screen.

5. C Program Example
#include <stdio.h>
int main() {
int a, b, sum;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);
sum = a + b;
printf("The sum is: %d\n", sum);
return 0;
}
📘 Developing an Algorithm in C
Programming
🌟 What is an Algorithm?
An algorithm is a step-by-step procedure to solve a problem.
It is written in simple English, not in programming [Link]: What needs to be
done (logic of solving the problem).
Think of it as a recipe: just like a cooking recipe tells you steps to make a dish, an algorithm
tells you steps to solve a problem.

🌟 Characteristics of a Good Algorithm


Clear and simple – Easy to understand.
Step-by-step – Each step should follow logically.
Finite – Must end after a certain number of steps.
Effective – Should solve the problem correctly.

🌟 Steps in Developing an Algorithm


Understand the problem – What is the input and what output is required?
Plan the process – What operations are needed to reach the output?
Write the steps – Present in a clear sequence.
Check with examples – Make sure it works with sample inputs.

🌟 Example Problem: Find the Largest of Two Numbers


Algorithm

Start
Read two numbers a and b
If a > b, then a is the largest
Otherwise, b is the largest
Print the largest number
Stop
🌟 Example Problem: Find the Factorial of a Number
Algorithm

Start
Read a number n
Set fact = 1
Repeat steps until n > 0
Multiply fact = fact * n
Decrease n by 1
Print fact
Stop

🌟 Example Problem with C Program: Sum of Two


Numbers
Algorithm

Start
Input two numbers a and b
Add them → sum = a + b
Display sum
Stop

C Program
#include <stdio.h>
int main() {
int a, b, sum;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);
sum = a + b;
printf("The sum is: %d\n", sum);
return 0;
}
Flowchart and Pseudocode in C
Programming
🌟 1. What is a Flowchart?
A flowchart is a diagram that represents the steps of an algorithm using symbols and
arrows.

It is a visual tool to understand logic.


Each step of the algorithm is shown in a box, and arrows show the sequence.

Common Flowchart Symbols

Oval → Start / Stop


Parallelogram → Input / Output
Rectangle → Process (calculation, assignment)
Diamond → Decision (yes/no, true/false)

Example 1: Find the Sum of Two Numbers

Algorithm:

Start
Input two numbers a and b
Add them → sum = a + b
Print sum
Stop

Flowchart:

┌───────┐
│ Start │
└───┬───┘


┌─────────────┐
│ Input a, b │
└─────┬───────┘


┌───────────────┐
│ sum = a + b │
└─────┬─────────┘


┌─────────────┐
│ Print sum │
└─────┬───────┘


┌───────┐
│ Stop │
└───────┘

🌟 2. What is Pseudocode?
Pseudocode is a plain English description of the steps in a program.

Not actual C code, but written so it looks similar to programming.


Written in a structured way (with keywords like IF, ELSE, WHILE, etc.) so that it looks
similar to a program.
It is not an actual programming language, but it helps programmers to easily convert logic
into real code.
Helps in moving from algorithm → program easily.

Example 2: Largest of Two Numbers

Pseudocode:

START
READ a, b
IF a > b THEN
PRINT a is largest
ELSE
PRINT b is largest
ENDIF
STOP

Equivalent C Program:

#include <stdio.h>
int main() {
int a, b;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);

if(a > b)
printf("%d is largest\n", a);
else
printf("%d is largest\n", b);

return 0;
}

🌟 Key Points
Flowchart = Graphical representation of the algorithm.
Pseudocode = Textual (English-like) representation of the algorithm.
Both are intermediate steps before writing the actual C program.

✅ In short:
Algorithm → Pseudocode → Flowchart → C Program

You might also like