Skip to content

Instantly share code, notes, and snippets.

@znarfm
Last active March 1, 2025 15:20
Show Gist options
  • Save znarfm/22febf51aa856102d482e093aaa932f1 to your computer and use it in GitHub Desktop.
Save znarfm/22febf51aa856102d482e093aaa932f1 to your computer and use it in GitHub Desktop.
elec ans

Elec Assignment

1. Flowchart to Output the Largest Number Among Three Numbers

flowchart TD
    A(Start) --> B[/Input A, B, C/]
    B --> C{Is A > B?}
    C -- Yes --> D{Is A > C?}
    D -- Yes --> E[/Output A/]
    D -- No --> F[/Output C/]
    C -- No --> G{Is B > C?}
    G -- Yes --> H[/Output B/]
    G -- No --> I[/Output C/]
    E --> J(End)
    F --> J
    H --> J
    I --> J
Loading

Pseudo:

  • Input 3 numbers
  • Compare A and B. If A > B, compare A with C.
  • If A > C, A is the largest; otherwise, C is.
  • If A <= B, compare B with C.
  • If B > C, B is the largest; otherwise, C is.
  • All paths lead to an end node.

2. Flowchart to Output the Greatest Common Factor (GCF) of Two Numbers

flowchart TD
    A(Start) --> B[/Input A and B/]
    B --> C{Is A < B?}
    C -- Yes --> D[Set min = A]
    C -- No --> E[Set min = B]
    D --> F[Set i = min]
    E --> F
    F --> G{i >= 1}
    G -- Yes --> H{Is A % i == 0 and B % i == 0?}
    H -- Yes --> I[/Output i/]
    H -- No --> J[Set i = i - 1]
    J --> G
    I --> K(End)
Loading

3. Flowchart to Output the Factorial of a Given Number

flowchart TD
    start(Start) --> read[/Input N/]
    read --> variables["`Set answer = 1
                         Set i = 1`"]
    variables --> condition{i <= N}
    condition -- Yes --> increm["`Set answer = answer * i
                                  Set i = i + 1`"] 
    increm --> condition
    condition -- No --> out[/Output answer/] --> last(End)
Loading

4. Flowchart to Output the Fibonacci Series Up to a Given Number N

flowchart TD
    start[Start] --> input[/Input N/]
    input --> init["`Set a = 0
                     Set b = 1`"] 
    --> condition{a <= N}

    condition -- No --> last[End]
    
    condition -- Yes --> print[/Output a/]
    print --> next["`Set temp = a + b
                     Set a = b
                     Set b = temp`"] 
    next --> condition

Loading

5. Flowchart to Output All Prime Numbers Between Two Numbers A and B

wait lng

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment