0% found this document useful (0 votes)
28 views

Variable Rules and Flowchart

The document discusses rules for declaring variables in C++ including allowed characters and syntax. It also covers algorithm design, flowcharts and pseudocode as tools for planning algorithms to be implemented in computer programs.

Uploaded by

SAIMA SHAHZADI
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Variable Rules and Flowchart

The document discusses rules for declaring variables in C++ including allowed characters and syntax. It also covers algorithm design, flowcharts and pseudocode as tools for planning algorithms to be implemented in computer programs.

Uploaded by

SAIMA SHAHZADI
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Rules for Declaring Variables in C++

 A variable name can consist of Capital letters A-Z, lowercase letters a-z, digits 0-9, and the
underscore character.
 The first character must be a letter or underscore.
 Blank spaces cannot be used in variable names.
 Special characters like #, $ are not allowed.
 C++ keywords cannot be used as variable names.
 Variable names are case-sensitive.
 A variable name can be consisting of 31 characters only if we declare a variable more than one
characters compiler will ignore after 31 characters.
 Variable type can be bool, char, int, float, double, void or wchar_t.

Algorithm Design

 In the problem-solving phase of computer programming, you will be designing algorithms.


 This means that you will have to be conscious of the strategies you use to solve problems in
order to apply them to programming problems.
 These algorithms can be designed through the use of flowcharts or pseudocode.

Flowchart
 Flowchart is a graphical representation of an algorithm
 Flowcharting is a tool developed in the computer industry, for showing the steps involved in a
process.
 A flowchart is a diagram made up of boxes, diamonds and other shapes, connected by arrows -
each shape represents a step in the process, and the arrows show the order in which they occur
 Flowcharting combines symbols and flowlines, to show figuratively the operation of an
algorithm
 In computing, there are dozens of different symbols used in flowcharting (there are even
national and international flowcharting symbol standards)

Flowcharting
 Symbols There are 6 basic symbols commonly used in flowcharting of assembly language
programs: Terminal, Process, input/output, Decision, Connector and Predefined Process.
 This is not a complete list of all the possible flowcharting symbols, it is the ones used most
often in the structure of Assembly language programming

 General Rules for flowcharting


 All boxes of the flowchart are connected with Arrows. (Not lines)
 Flowchart symbols have an entry point on the top of the symbol with no other entry points. The
exit point for all flowchart symbols is on the bottom except for the Decision symbol
 The Decision symbol has two exit points; these can be on the sides or the bottom and one side
 Generally a flowchart will flow from top to bottom. However, an upward flow can be shown as
long as it does not exceed 3 symbols.
 Connectors are used to connect breaks in the flowchart.
 Examples are:
 • From one page to another page.
 • From the bottom of the page to the top of the same page.
 • An upward flow of more than 3 symbols
 Subroutines and Interrupt programs have their own and independent flowcharts.
 All flow charts start with a Terminal or Predefined Process (for interrupt programs or
subroutines) symbol. 8. All flowcharts end with a terminal or a contentious loop

Examples of Algorithms and Flowcharts Example

1. Design an algorithm and the corresponding flowchart for adding the test scores as given
below: 26, 49, 98, 87, 62, 75
a) Algorithm
1. Start
2. Sum = 0
3. Get the first testscore
4. Add first testscore to sum
5. Get the second testscore
6. Add to sum
7. Get the third testscore
8. Add to sum
9. Get the Forth testscore
10. Add to sum
11. Get the fifth testscore
12. Add to sum
13. Get the sixth testscore
14. Add to sum
15. Output the sum
16. Stop
Pseudocode
 Pseudocode is one of the tools that can be used to write a preliminary plan that can be
developed into a computer program
 Pseudocode is a generic way of describing an algorithm without use of any specific
programming language syntax.
 It is, as the name suggests, pseudo code —it cannot be executed on a real computer, but
it models and resembles real programming code, and is written at roughly the same
level of detail

You might also like