Developing Flowcharts
In developing the flowcharts following points have to be considered:
• Defining the problem.
• Identify the various steps required to form a solution.
• Determine the required input and output parameters.
• Get expected input data values and output result.
• Determine the various computations and decisions involved.
Example: To prepare a flowchart to add two numbers. The steps are:
1. Start.
2. Get two numbers N1 and N2.
3. Add them.
4. Print the result.
5. Stop.
Example: To prepare a flowchart to determine the greater of two numbers. Here we use the
decision symbol. We also combine the two reads for numbers A and B in one box.
The steps are:
1. Start
2. Get two number A and B.
3. If A > B then print A else print B.
4. Stop.
Example : Flowchart for a program that converts temperature in degrees Celsius to degrees
Fahrenheit.
First let us write the steps involved in this computation technique.
1. Start.
2. Create memvars F and C (for temperature in Fahrenheit and Celsius).
3. Read degrees Celsius into C.
4. Compute the degrees Fahrenheit into F.
5. Print result (F).
6. Stop.
Example: Flowchart to get marks for 3 subjects and declare the result. If the marks >= 35 in all
the subjects the student passes else fails.
The steps involved in this process are:
1. Start.
2. Create memvars m1, m2, m3.
3. Read marks of three subjects m1, m2, m3.
4. If m1 >= 35 goto step 5 else goto step 7
5. If m2 >= 35 goto step 6 else goto step 7
6. If m3 >= 35 print Pass. Goto step 8
7. Print fail
8. Stop
Example: To find the sum of first N numbers. This example illustrates the use of a loop for a
specific number of times.
The steps are:
1. Start
2. Create memvars S , N, I
3. Read N
4. Set S (sum) to 0
5. Set counter (I) to 1.
6. S = S + I
7. Increment I by 1.
8. Check if I is less than or equal to N. If no, go to step 6.
Structure of a simple Program in C
#include<stdio.h> //inclusion of header file
#include<conio.h>
int add( int,int); //function declaration or prototype
void main() //main function
{
int a, b, c; //Declaration of variable
printf("enter the vale of a \n");
scanf("%d", &a);
printf("enter the vale of b \n");
scanf("%d", &b);
c=add(a,b); //function call
printf("sum of %d and %d is %d",a,b,c);
getch();
}
int add( int a, int b) //function definition
{
int c;
c=a+b;
return c;
}