Iterative Statement : for Loop

For some programming objectives it is necessay to repeat a set of statements a number of times until a certain condition is fulfilled. In such situations iteration statements can be used. The iteration statements are also called loops or looping statements.
Parts of a loop
1. Initialization Expression.
2. Test Expression
3. Update Expressions
4. Body of the loop.
The for Loop
The for loop is a deterministic loop in the sense that the program knows inadvance how many times the loop is to be executed.

The Selective Structure : switch

The syntax of the switch instruction is a bit peculiar. Its objective is to check several possible constant values for an expression, something similar to what we did at the beginning of this section with the linking of several if and else if sentences. Its form is the following:
switch (expression)
case constant1:
block of instructions 1
case constant2:
block of instructions 2
break; . . .
default: default block of instructions

Program Control Statements

The program flow in high - level languages is sequential. A program is usually not limited to a linear sequence of instructions. Therefore there is a use of control structures that serve to specify what to do with our program and how.
C++ provides statemets to perform efficiently and effectively. Such statements are called program control statements. These are selection statements ( if and switch), iteration statements (for, while and do-while) and jump statements such as (return, goto, exit(), break and continue)
Statements are instructions given to the computer to perform an action such as moving data, taking decisions or repeating actions. LEARN MORE>>


An Expression is comprised of one or more operations. The objects of the operation(s) is reffered to as operands. the conditions are represented by operators.
A C++ expression is a combination of operations, constants, and variables.
An expression is any statement which is composed of one or more operands and returns a value. It may be a combination of operators, variables and constants. the expression may be simple or complex.
Rules of formation of expression: LEARN MORE>>

Precedence of Operators

Precedence and associativity are the two important properties of operators. Precedence is the order in which a program performs / evaluates the operation in a formula. All operators have a precedence value. An operator with higher precedence is evaluated before an operator with a lower precedence value.
When making complex expressions with several operands, we may have some doubts about which operand is evaluated first and which later. For example, in this expression:
a = 5 + 7 % 2 LEARN MORE >>

Operators & Expressions in C++

An operator is a symbol or letter which makes the compiler perform a specific operation on operands (variables) in a program.
An expression is a combination of operands ( i.e, constants, variables, numbers), and operators that perform a specific operation and parenthesis.
An expression is a sequence of operators that specifies a computation. an expression may result in a numerical value.
For example: x+y is an expression in which the sign + is an operator which specifies the addition operation. LEARN MORE >>

Structure of a C++ Program

The structure of a C++ program is as described below:-
1. At the top of the program header files are declared.
2. A C++ prgram starts executing from main() function. The body of the main function is included with surly braces.
3. Each of the statment of the C++ program must end with a semicilon. a semicilon is also known as statement terminator.
So my first program would probably be:- LEARN MORE>>

Use of I/O Operators

INPUT / OUTPUT statements of C++ can be used for input of data from an input device such as a keyboard or to obtain output on output devices such as VDUs and printers.
In C++, input/output devices are treated as files; files are treated as a sequence or a stream of bytes. In other words, a stream in C++ means a flow of bytes from an input device to the CPU(input stream) and from the CPU to an output device (output stream).
Streams used for input and output are: LEARN MORE >>


Operators: Operators are tokens that perform some computation when applied to variables and other objects in an expression. they can be unary or binary.
Unary Operators: Unary operators require one operator to operate upon. The following are examples of unary operators.
& Address operator
* Indirection operator
+ Unary plus
- Unary minus
~ Bitwise operator
++ increment operator
-- decrement operator
! Logical NOT LEARN MORE>>

C++ Tokens

One of the first jobs performed by a compiler is to read in the source code and group individual characters into tokens., the lowest level of symbols used in defining a programming language.
A C++ compiler always collects characters into the longest possible tokens, using white spaces to demarcate them. White spaces must be used to seperate an identifier, reserved word, integer constant, floating point constant from a following identifier, reserved word, integer constant or floating point constant and arithmetic or boolean operators. LEARN MORE>>

Data Types

Data type is defined as the set of possible values a variable can hold. Data types in C++ can be divided into three categories:

  1. Built-in Data Type
  2. User Defined Data Type
  3. Derived Data Type

Built-in Data Types
The C++ compiler supports all the built-in data types. These data types are also known as standard data types and ae not composed of other data types. LEARN MORE>>

C++ Character Set

Character sets affect the fundamental part of the program code, the storage and transmission of data and the logic with which you manipulate text.
The Character set inC++ includes the following"
Source Code Character Set
A C++ compiler may use any character set that includes at least the following characters: LEARN MORE >>

Introduction to C++

C++ (C plus plus) is a general purpose programming language based on the C programming language. In addition to facilities provided by C, C++ provides classes, inline functions, operator overlaoding, constant type references, free store management operators, etc.
C++. Learn More