[Android General] mhrsolanki2020:
Chapter 5

Subroutines And Off-Page-Connector​

​

==================================================================

So as you have seen many flow charts above, u have came to an end of learning the flow chart, are are soon going to learn about C programming.

==================================================================

So lets talk about Subroutine:

What is Subroutine?

-> It is a symbol used in Flow charts to represent the programs clearly.

You will understand it after you see the flow chart bellow.

Lets suppose you were to make a program to add the numbers (we did it before in Chapter 3) , but using subroutine makes it tidy graphical Representation , and also it is easy to understand while reading it. :

As you can see above , the function of adding the two numbers is separated from the flowchart for better representation , this is known as an Modular Approach of Programming.

(not talking just about FlowCharts , i Am talking of C programming language .)

Modular Approach of programming is , to keep the main code in a file , and then the operating codes in a separate file , as you can see above, the main code is separated from the code that adds the numbers.

It is not of a great help when such a small flowchart, but when u have a full calculator in which you would add , subtract , multiply , divide etc etc , this approach would be the best . :good:

NOTE:at the end of the subroutine , we use a terminator with "RETURN" , and not "STOP"

==================================================================

Lets take another Example.:

You wanted to make a flowchart of a program , a program that adds and subtracts both .

Then it would be represented this way :

(all the three images is one FlowChart Only)

Each image above is like a different page in a book.

So if your flow chart ever exceeds the page in a book or page in any document, then you use the off page Connector.

Lets first talk about subroutine.

As u can see above, the Subroutines add and subtract are separated from the flowchart , you can write it on any page as long as those pages are kept together .

When the page comes to an end, we use a Off-Page-Connector, and then name it what ever we like, and in a new page we make a new Off-Page-Connector with the same name, as you can see a connector with name "A" is on the both page, so the connector "A" on the first page , conects with the conector "A" on the second page , Same way with the connectors named "B"

====================================================================

One more eg and we are done With Flowcharts

A flowchart , to show a program .

The program takes the marks of the students who gave an entrance exam for College, Subjects are Math,English and French. If in each subject a student scores atleast 35 marks and the average of the 3 subject is atleast 50 marks , Then a selection letter from the college is sent , if not , then a rejection letter is sent. Also count the number of selection letters and rejection letters sent.

Note:I wont explain this flow chart. If you can understand it on your own then you are good to go further with C programming , if you cant then please read the chapters again and try understanding it again and then proceed with programming.

The only new thing in this is :

nSelect = nSelect + 1

Lets suppose nSelect is a variable with a value 0 in it , then you can say

nSelect = nSelect + 1 which means , nSelect = 0 + 1

And then suppose nSelect is 1 then

nSelect = nSelect + 1 means nSelect = 1+1 which comes to two.

You can use such type of statements in programing .

Remember ,

The Right Hand Side of an equation is calculated and then stored in the variable Left Hand Side,

NSelect + 1 is calculated and the ans is stored in nSelect on the Left Hand Side. It works as an counter.

And yeah!! you are done with flowcharts.. We will start with Programming ASAP ..