Errors+Flow Charts
Errors+Flow Charts
Start
printf("");
scanf("”);
TRUE
intNum ==
3? printf("");
printf("");
FALSE
printf("");
G?
R?
The switch-case-break
program source code e
T xample
T printf("");
Y? break;
printf("");
F
printf("");
Stop
PROGRAM CONTROL
if, if-else and switch-case-break flow charts
PROGRAM CONTROL
The for loop flow chart should be something like the following.
Start
Evaluate initial_value
Do increment/ decrement
Evaluate
condition(s) Execute statement(s)
Stop
PROGRAM CONTROL
A Simple for example, printing integer 1 to 10.
#include <stdio.h>
void main(void)
{
int nCount;
// display the numbers 1 to 10
for(nCount = 1; nCount <= 10; nCount++)
printf("%d ", nCount);
printf("\n");
}
PROGRAM CONTROL
Its flow chart…
Start
nCount = 1
nCount++
nCount <=10?
printf("…");
Stop
Examples
Consider a problem of multiplying two
numbers
Algorithm
Step1: Input the numbers as a and b
Step2: find the product a x b
Step3: Print the result
Examples
• To find the highest of three numbers
• Algorithm
• Step 1: read the numbers as x ,y and z
• Step 2: compare x and y
• Step 3: if x > y then compare x with z and find
the greater
• Step 4: Otherwise compare y with z and find
the greater
END