Articles in the C and C++ Category
C and C++, Tech Corner »
The process of splitting the lengthy and comlex programs into a number of smaller units(called modules or sub-programs) is called modularization.
Programming in such an approach is called modular programming.
Modularization offers several advantages – Reusability, Debugging is easier, Build libraray.
Functions – A function is a set of instructions to carryout a particular task.
The function, after it’s executions, returns a single value.
Classified into standard functions and user-defined functions.
Function Definition – Defining a function means writing an actual code for the function which performs a specific and identifiable task.
Two ways – Non-ANSI style …
C and C++, Tech Corner »
A programming language construct which stores and organizes a set of data items is called a data structure.
There are different types of data structures – arrays, stacks, queues, linked lists, structures, trees, files, etc.
An array can be defined as an ordered list of homogeneous data elements.
These elements may be of type int, float, char or double.
All these elemets are stored in consecutive memory locations.
An array is described by a single name or an identifier.
And each element in an array is referenced by a subscript(or an index) enclosed in a pair …
C and C++, Tech Corner »
Looping is a powerful programing technique through which a group of statements is executed repeatedly, until certain specified condition is satisfied.
Looping is also called a repetitive or an iterative control mechanism.
A loop in a program essentially consists of two parts, one is called the body of the loop and other is known as the control statement.
The control statement performs a logical test whose result is either true or false. If the result of this logical test is true, then the statements contained in the body of the loop are executed. …
C and C++, Tech Corner »
Normally, the statements in a program are executed in the order in which they appear in the program. This type of execution is called sequential execution.
Control structures – define the order of execution of statements.
Conditional control statements – involves both decision making and branching.
if-statement.
if-else statement.
Nested-if-statement.
switch statement.
if-statement – used to execute a statement or a set of statements conditionally.
Also called a one-way branching.
Syntax -
if (condition)
{
statement;
}
if-else statement – The if statement is used to execute only one action. If there are two statements to be executed alternatively, then if-else statement is used.
Two-way …
C and C++, Tech Corner »
Operators are used to carryout the arithmetic and logical operations.
Operators act as connectors.
The values that can be operated by these operators are called operands.
C operators – unary operators, binary operators, ternary operators.
An operator that acts upon only one operand is known as a unary operator.
Egs – unary minus, logical NOT, bitwise complementation.
Binary operators act upon two operands.
Classified into four – arithmetic operators, logical operators, relational operators, bitwise operators.
Arithmetic operators are used to perform basic arithmetic operations such as addition, subtraction, multiplication and division.
An expression involving arithmetic operators is called an arithmetic …