Mockitt - Flowchart Maker

Flowchart - Help Your Work More Efficient and Effective

  • Complete guide on creating all types of flowchart.
  • Plenty of flowchart examples and templates for inspiration.
  • Best flowchart software recommendation.
  • Basic flowchart knowledge to understand flowchart better.
prototyping

Flowchart Examples in C: Seven Programs and Logic Checks

Trace seven C flowchart examples, including sums, even or odd, factorials and averages, with corrected branches and concrete expected results.

Try Mockitt for Free
A C flowchart decision splitting into distinct even and odd outcomes

A flowchart in C represents the sequence of logical steps that a C program will implement. It uses simple shapes for actions, decisions, input and output, with arrows showing the possible routes. Programmers can plan and review a flowchart before coding to make those routes explicit. The seven examples below cover output, arithmetic, decisions, loops and a conceptual controller; each needs a trace as well as a drawing.

Seven flowchart examples for C

A flowchart helps you analyze, design and document a program. It can reveal an omitted branch or a loop that does not progress, but a diagram does not automatically validate the implementation. Use consistent input, output and decision symbols so readers can distinguish a calculation from a question.

These examples assume valid inputs in the stated domain. When implementing them, also handle failed input conversion and values outside the range of the chosen C data types.

1) Print message "Hello Everybody"

To display “Hello Everybody...”, begin at Start, follow the output shape and finish at End. A C implementation can use puts("Hello Everybody..."); with <stdio.h>. This path has no input or branch; the expected result is one displayed line.

Original Hello Everybody output flowchart and dry run

2) Input 2 numbers from the user and print their sum

Read the first number into a and the second into b, calculate sum = a + b, then output sum. Keep the two input variables distinct. For a = 7 and b = 5, the result is 12; for -3 and 3, it is 0. Use values whose sum fits the selected data type.

Two-number sum with distinct a and b inputs

3) Check whether an integer is even or odd

Read one integer num, then test num % 2 == 0. Follow Yes to “Even” or No to “Odd”; both output paths go directly to End. The two outputs are alternatives, so the Even path must not continue through Odd. Test 8, 7 and 0: the expected results are Even, Odd and Even. A yes/no branch should make that exclusive choice clear.

Even and odd outputs on exclusive branches

4) Flowchart to find the sum of the first 50 natural numbers

The next diagram accumulates the numbers from 1 through 50. Its loop should add each number exactly once and exit after adding 50. The expected total is 1275.

Original loop summing the natural numbers from 1 through 50

Initialize sum = 0 and n = 0. Increment n, add it to sum, and test whether n == 50. If not, return to the increment; otherwise print the sum. In C, equality uses ==, while = assigns a value. The equivalent loop is:

int sum = 0;
for (int n = 1; n <= 50; ++n) {
    sum += n;
}
/* sum is 1275 */

5) Find the factorial of a non-negative integer

For a non-negative integer n, initialize i = 1 and fact = 1. While i < n, increment i and multiply fact by i, then return to the condition. Only the No branch outputs the result and ends. For n = 0 or 1, the loop runs zero times and the result is 1; for 5, it is 120. Reject negative input and check for multiplication overflow before using this with larger values.

Factorial loop returning to its condition before a single exit

6) Trace a conceptual toaster controller

The main routine waits for the start button, calls Cook when pressed, then returns to checking the switch. Cook turns the heater on and reads the toast temperature. If the temperature is below the desired value, it reads again; once the value reaches or exceeds the target, it turns the heater off and returns. For a target of 80 and readings 60, 70, 80, the heat switches off at the third reading. This is a conceptual exercise: it omits timeouts, sensor faults and physical safety controls needed by a real appliance.

Original conceptual toaster main and Cook routines

7) Calculation of the average of two numbers

Read two numbers and calculate their sum divided by two, then display the average. The mathematical diagram leaves the data type unspecified. In C, (num1 + num2) / 2 truncates if both operands are integers. For small inputs such as 3 and 4, ((double)num1 + (double)num2) / 2.0 gives 3.5. The GNU C manual explains integer division and remainder; choose numeric types and ranges deliberately rather than assuming the diagram supplies them.

Original mathematical average of two numbers

Guidelines for Developing Flowcharts

These are some points to keep in mind while developing a flowchart −

  • Make the entry and all exits explicit. A single Start and End works well for these small examples, but one exit is not a universal rule.
  • Label on-page connectors consistently so each continuation is easy to find.
  • For an off-page connector, identify the destination page or diagram; letters and numbers are conventions, not mandatory alphabets.
  • Keep the main flow top to bottom or left to right, and mark loop-back arrows clearly.
  • Avoid crossing arrows where possible. Label decision routes and trace boundary inputs before translating the diagram into code.

Create a simple flowchart online with Mockitt

For a complex program, break the review into smaller procedures rather than trying to fit every detail into one diagram. In Mockitt, arrange the relevant actions and labeled connectors, then share the logic for a colleague to trace. A drawing supports that review; it is not a C compiler.

Historical Mockitt workspace displaying a travel prototype

For a focused example, put num = 8 beside the parity diagram and trace only the Yes route to “Even.” Then try num = 7 and follow No to “Odd.” This keeps the condition, its two alternatives and the expected results visible in one review scene.

Parity decision and two expected-result traces composed on a genuine historical Mockitt editor canvas
Each input reaches one output: 8 is even; 7 is odd.

Use a short label for each shape and keep the input domain beside the diagram. The historical Mockitt workspace image illustrates the editing environment; the parity scene focuses on the exercise logic.

After feedback, update the affected labels and connections, retrace both branches and test the C implementation separately. For loops, include an input that skips the loop, one that runs once and a small input that runs several times.