FC1
π for Loop β Init, Condition, Body, Update
Print 1 to 5 β four flowchart zones: initialise β test β body β update β loop back
for loop
A
for loop has four parts that map directly to flowchart zones: Init (rectangle β runs once), Condition (diamond β tested before every iteration), Body (rectangle β runs if condition is true), Update (rectangle β runs after body, then loops back to condition). The back arrow from Update to Condition is the visual signature of a loop β it shows the repeated cycle. When the condition becomes false, the No arrow exits the loop.
Flowchart for(i=1; i<=5; i++)
#include <stdio.h> int main() { /* β Init */ for (int i = 1; i <= 5; /* β‘ Condition */ i++) { /* β£ Update */ printf("%d\n", i); /* β’ Body */ } return 0; }
1 2 3 4 5
Four zones map exactly to the four parts of a
for statement. The flowchart loop-back arrow from Update β Condition is the visual proof that something repeats.fc2 β while loop
FC2
π while Loop β Condition at the Top, Body Below
Sum of digits of a number β condition tested BEFORE body β may never run
while loop
A
while loop tests its condition before entering the body β if the condition is false on the very first check, the body never executes. The flowchart shows this: the decision diamond comes immediately after the start/init, before any process box. The loop-back arrow goes from the bottom of the body directly back up to the diamond β skipping the init (which stays outside the loop). Example: extract digits of a number by repeatedly dividing by 10 until the number becomes 0.
Flowchart while(n > 0)
#include <stdio.h> int main() { int n = 5765, sum = 0; while (n > 0) { /* condition first */ sum += n % 10; /* last digit */ n /= 10; /* remove digit */ } printf("Digit sum = %d\n", sum); return 0; }
Digit sum = 23
Key difference from do-while: if
n = 0 at the start, the body never runs and sum stays 0. The condition diamond blocks entry to the body the moment it's false β even on the first check.fc3 β do-while loop
FC3
π do-while Loop β Body First, Condition at the Bottom
Menu input validator β body ALWAYS runs at least once β condition tested AFTER
do-while
The
do-while loop puts the condition diamond below the body. The body always executes at least once β guaranteed. The flowchart shows: Start β Body β Condition Diamond. If the condition is true, the arrow loops back up to the body (opposite direction from while). If false, it exits. Perfect for menu-driven programs where you must show the menu at least once before checking the choice.
Flowchart do { } while(choice < 1)
#include <stdio.h> int main() { int choice; do { /* body runs first */ printf("1.Add 2.Del 3.Exit\n"); printf("Enter choice: "); scanf("%d", &choice); } while (choice < 1 /* condition after */ || choice > 3); printf("Valid choice: %d\n", choice); return 0; }
1.Add 2.Del 3.Exit Enter choice: 0 1.Add 2.Del 3.Exit Enter choice: 2 Valid choice: 2
do-while vs while: In the flowchart, the loop-back arrow in do-while points upward to the body. In while, the loop-back arrow points upward to the condition diamond. This single difference is the entire distinction between the two loops.
fc4 β break
FC4
β break β Escape the Loop Immediately
Linear search β break exits the loop the moment the target is found
break
break adds a second exit path to the loop β the early exit. In the flowchart, there are now two arrows leaving the body: the normal loop-back arrow, and a new break arrow that jumps out of the loop entirely, bypassing the condition check. A second decision diamond inside the body represents the if that triggers the break. The moment it fires, execution jumps past the loop to the next statement.
Flowchart break on found
#include <stdio.h> int main() { int arr[] = {10,20,30,40,50}; int n=5, target=30, found=-1; for(int i=0; i<n; i++) { if(arr[i] == target) { found = i; break; /* EXIT loop NOW */ } } if(found >= 0) printf("Found at index %d\n",found); else printf("Not found\n"); return 0; }
Found at index 2
break only exits ONE loop. In nested loops,
break only exits the innermost loop it is inside. The outer loop continues. Use a flag variable or goto if you need to exit multiple loops at once.fc5 β continue
FC5
βοΈ continue β Skip This Iteration, Loop Again
Print odd numbers only β continue skips even numbers, jumps back to update
continue
continue does not exit the loop β it skips the rest of the current iteration and jumps directly to the update step (for a for loop) or back to the condition (for a while loop). In the flowchart, the continue arrow bypasses the remaining process boxes in the body and connects directly to the update/condition β it is a short-circuit back to the top, not an exit. The loop keeps running; you just skipped this one iteration.
Flowchart continue skips even
#include <stdio.h> int main() { printf("Odd numbers 1-10:\n"); for(int i=1; i<=10; i++) { if(i % 2 == 0) continue; /* skip even β jump to i++ */ printf("%d\n", i); /* only reached for odd i */ } return 0; }
Odd numbers 1-10: 1 3 5 7 9
continue in for vs while: In a
for loop, continue jumps to the update expression (i++) first, then to the condition. In a while loop, continue jumps directly to the condition. If you put the update inside a while body after a continue, it gets skipped β this causes an infinite loop.fc6 β nested loops with break + continue
FC6
π Nested Loops β Connector Symbols + break in Inner Loop
Multiplication table β inner loop uses connector circles to keep flowchart readable
Nested + Connector
When loops are nested, flowcharts become complex. Connector circles (labeled A, B, Cβ¦) allow the chart to jump between sections without crossing arrows everywhere β you draw circle A at the exit and circle A again at the entry point, and the reader knows they connect. The inner loop for a multiplication table also demonstrates
break inside a nested loop β the break only exits the inner loop, and the outer loop continues.
Flowchart β nested for loops with connector symbols
#include <stdio.h> int main() { for(int i=1; i<=3; i++) { /* outer loop β connector A enters inner */ for(int j=1; j<=5; j++) { /* inner loop */ printf("%dΓ%d=%-3d ", i, j, i*j); } /* connector B returns to outer */ printf("\n"); } return 0; }
1Γ1=1 1Γ2=2 1Γ3=3 1Γ4=4 1Γ5=5 2Γ1=2 2Γ2=4 2Γ3=6 2Γ4=8 2Γ5=10 3Γ1=3 3Γ2=6 3Γ3=9 3Γ4=12 3Γ5=15
Connector circles (A, B) are the flowchart equivalent of
goto labels β they name a point in the flow so you can connect it from elsewhere without drawing a long crossing arrow. Use them whenever an arrow would cross another or the flowchart becomes too wide.fc7 β goto
FC7
π·οΈ goto β Jump to a Label Anywhere in the Function
Exit nested loops instantly β goto jumps directly to a labelled point β use with care
goto
goto causes an unconditional jump to a labelled statement anywhere in the same function. In the flowchart, a goto is represented as an arrow that crosses over normal flow and lands at a labelled connector or process box. The most legitimate use of goto in C is breaking out of multiple nested loops β where a single break only exits the innermost loop. With goto, you jump directly to code after all the loops.
Flowchart β goto exits nested loops in one jump
#include <stdio.h> int main() { int grid[3][3] = {{1,2,3},{4,-1,6},{7,8,9}}; for(int i=0; i<3; i++) { for(int j=0; j<3; j++) { printf("Check [%d][%d]=%d\n",i,j,grid[i][j]); if(grid[i][j] < 0) goto error_exit; /* jump over BOTH loops */ } } printf("All values OK.\n"); return 0; error_exit: /* label β goto lands here */ printf("Error: negative value found!\n"); return 1; }
Check [0][0]=1 Check [0][1]=2 Check [0][2]=3 Check [1][0]=4 Check [1][1]=-1 Error: negative value found!
Use goto sparingly. The only widely accepted use of
goto in C is exiting nested loops or centralised error/cleanup handling (common in Linux kernel code). Never use it to jump into a loop, over initialisations, or create spaghetti flow. In modern C, prefer a flag variable or restructuring functions over goto in most cases.checklist
- Flowchart symbols: Oval = Start/End. Rectangle = Process. Diamond = Decision (Yes/No). Parallelogram = Input/Output. Circle = Connector. Arrow = flow direction.
- FC1 β for loop: Four zones β Init (once), Condition (diamond before body), Body, Update. Loop-back arrow from Update β Condition. NO arrow exits loop.
- FC2 β while loop: Condition diamond comes BEFORE body. If false on first check, body never runs. Loop-back arrow goes from body bottom directly up to condition diamond.
- FC3 β do-while: Body comes BEFORE condition diamond. Body always runs at least once. YES arrow from condition loops BACK UP to body. NO arrow exits.
- FC4 β break: Second inner decision diamond inside body. YES β break arrow exits loop entirely downward. Resumes at first statement AFTER the loop. Only exits ONE level.
- FC5 β continue: Inner decision. YES β continue arrow bypasses rest of body and goes directly to Update (for) or Condition (while). Loop does NOT exit β next iteration starts.
- FC6 β nested + connector: Connector circles (A, B) label entry/exit points so arrows don't cross. A connects outer-YES to inner loop entry. B connects inner-NO back to outer update.
- FC7 β goto: Long arrow crosses loop boundaries and lands at labelled statement. Only accepted use: exit nested loops or centralised error handling. Never jump INTO loops.