🧪
Lab 1 — Algorithms & Flowcharts (10 Programs)
Lab 1: Intro 🏠 Home
PSUC Lab 1 — Problem Solving Foundation

Algorithms & Flowcharts (10 Programs)

Every problem follows a systematic solution path: Problem Definition → Algorithm → Flowchart → C Source Code. Step through all 10 lab manual experiments interactively below!

Standard Flowchart Symbols

SymbolShapePurpose & Description
TerminalCapsule / OvalStart or Stop point of execution
Input / OutputParallelogramReading input (`scanf`) or Printing output (`printf`)
ProcessRectangleCalculations, formula evaluation, assignments
DecisionDiamondConditional check (`if-else`) with Yes / No paths
ConnectorCircleJoins flowchart lines from different paths
Flow LineArrow LineShows exact direction of CPU execution

Interactive Symbol Inspector

Click on a flowchart shape below to inspect its exact C programming mapping:

Click any shape above to inspect its C equivalent!
Program 1 of 10

To Multiply Two Numbers

Accept two integers a and b, compute their product product = a × b, and display the result.

Algorithm Steps

  1. Step 1: Start
  2. Step 2: Read integers a and b
  3. Step 3: Compute product = a * b
  4. Step 4: Display product
  5. Step 5: Stop
Click "Next Step ▶" to begin execution...

Detailed Flowchart Diagram

Start Read a, b product = a * b Print product Stop
Program 2 of 10

To Divide Two Numbers (With Decision Branching)

Read numerator a and denominator b. Test b != 0 with YES (True) and NO (False) flowchart decision branches.

Algorithm Steps

  1. Step 1: Start
  2. Step 2: Read integers a and b
  3. Step 3: If b == 0 then Print "Division by Zero Error" and goto Step 6
  4. Step 4: Compute quotient = (float)a / b
  5. Step 5: Display quotient
  6. Step 6: Stop
Click "Next Step ▶" to divide...

Detailed Decision Flowchart

Start Read a, b b != 0 ? YES NO quot = (float)a / b Print Quotient Stop
Program 3 of 10

To Check Even or Odd (Two Branch Flowchart)

Evaluate n % 2 == 0. Follow YES branch for Even and NO branch for Odd.

Algorithm Steps

  1. Step 1: Start
  2. Step 2: Read integer n
  3. Step 3: If n % 2 == 0 then Print "Number is Even" and goto Step 6
  4. Step 4: Print "Number is Odd"
  5. Step 5: Stop
Click "Next Step ▶" to check even/odd...

Detailed Decision Flowchart

Start Read n n % 2 == 0 ? YES NO Print Even Print Odd Stop
Program 4 of 10

To Swap Two Numbers

Exchange values of a and b using temporary variable temp.

Algorithm Steps

  1. Step 1: Start
  2. Step 2: Read integers a and b
  3. Step 3: Assign temp = a
  4. Step 4: Assign a = b
  5. Step 5: Assign b = temp
  6. Step 6: Display swapped values of a and b
  7. Step 7: Stop
var a10
var b25
var temp—
Click "Next Step ▶" to swap...

Detailed Flowchart Diagram

Start Read a, b temp = a a = b b = temp Print a, b Stop
Program 5 of 10

To Check Whether Number is < 10

Evaluate n < 10. Follow YES branch if <10 and NO branch if ≥10.

Algorithm Steps

  1. Step 1: Start
  2. Step 2: Read integer n
  3. Step 3: If n < 10 then Print "Lesser than 10" and goto Step 5
  4. Step 4: Print "Not lesser than 10"
  5. Step 5: Stop
Click "Next Step ▶" to check...

Detailed Decision Flowchart

Start Read n n < 10 ? YES NO Print <10 Print ≥10 Stop
Program 6 of 10

To Convert Fahrenheit to Celsius

Convert temperature from Fahrenheit to Celsius using formula: C = (F − 32) × 5/9.

Algorithm Steps

  1. Step 1: Start
  2. Step 2: Read temperature in Fahrenheit F
  3. Step 3: Compute Celsius C = (F - 32) * 5 / 9
  4. Step 4: Display temperature in Celsius C
  5. Step 5: Stop
Click "Next Step ▶" to convert...

Detailed Flowchart Diagram

Start Read F C = (F - 32) * 5/9 Print C Stop
Program 7 of 10

To Check Greater of Two Numbers

Evaluate a > b. Follow YES branch if a > b and NO branch if b ≥ a.

Algorithm Steps

  1. Step 1: Start
  2. Step 2: Read integers a and b
  3. Step 3: If a > b then Print "a is Greater" and goto Step 5
  4. Step 4: Print "b is Greater"
  5. Step 5: Stop
Click "Next Step ▶" to compare...

Detailed Decision Flowchart

Start Read a, b a > b ? YES NO Print a Max Print b Max Stop
Program 8 of 10

To Calculate Simple Interest

Calculate simple interest SI = (P × R × T) / 100.

Algorithm Steps

  1. Step 1: Start
  2. Step 2: Read Principal P, Rate R, and Time T
  3. Step 3: Compute Simple Interest SI = (P * R * T) / 100
  4. Step 4: Display SI
  5. Step 5: Stop
Click "Next Step ▶" to calculate...

Detailed Flowchart Diagram

Start Read P, R, T SI = (P * R * T) / 100 Print SI Stop
Program 9 of 10

To Check Whether Given Number is Prime

Interactive algorithm and flowchart to determine if an integer is prime using trial division up to n / 2.

Algorithm Steps

  1. Step 1: Start
  2. Step 2: Read integer n
  3. Step 3: If n < 2 then Print "Not Prime" and goto Step 8
  4. Step 4: Initialize loop counter i = 2
  5. Step 5: If i > n / 2 then Print "Prime Number" and goto Step 8
  6. Step 6: If n % i == 0 then Print "Not Prime" and goto Step 8
  7. Step 7: Increment i = i + 1 and goto Step 5
  8. Step 8: Stop
Number n29
Counter i—
Limit n/214
Click "Next Step ▶" to test prime...

Prime Number Flowchart

Start Read n n < 2 ? YES NO i = 2 i ≤ n / 2 ? YES NO n % i == 0 ? YES NO i = i + 1 Print Not Prime Print Prime Stop
Program 10 of 10

To Calculate Area of Rectangle

Given length (L) and breadth (B), compute rectangle area: Area = L × B.

Algorithm Steps

  1. Step 1: Start
  2. Step 2: Read length L and breadth B
  3. Step 3: Compute Area = L * B
  4. Step 4: Display Area
  5. Step 5: Stop
Click "Next Step ▶" to calculate area...

Detailed Flowchart Diagram

Start Read L, B Area = L * B Print Area Stop
Knowledge Check

Test Your Algorithm & Flowchart Mastery

Question 1 of 5
Loading question...