Posts

Array

Image
  Array:             In many applications, we need to handle a large volume of data in terms of reading, processing and printing. To process such large amount of data, we need a powerful data type that facilitate efficient sorting, accessing and manipulation of data items. C++ supports a derived data type known as array that can be used for such applications.             Array is an important part of almost all programming language. It provides an powerful feature and can be used to form complex data structures like stack and queue. Definition: An array can be defined as a collection of homogeneous (similar type) elements. An array is a fixed size sequenced collection of elements of the same data type.             This means that an array can store all integers, all floats, all characters or any other data t...

Variables in C++

Image
 Variables in C++: A variable is a name given to a memory location. It is the basic unit of storage in a program. The value stored in a variable can be changed during program execution. A variable is only a name given to a memory location, all the operations done on the variable effects that memory location. In C++, all the variables must be declared before use. A particular type of variable can hold only the same type of value. For example, an integer variable can hold only an integer value, a real variable can hold only a real value and a character variable can hold only a character. Declaration of Variables:- Declaration does two things: 1.       Tells the compiler what the variable name is, 2.       It specifies what type of data the variable will hold. The declaration of variable is must be done before it is use in a program Syntax:              ...

Symbolic Constants

  Symbolic Constants:- A symbolic constant is name that substitute for a sequence of character that cannot be changed i.e. constant. Constants in C++ refer to fixed values. Constant values do not change during the execution of a program. These fixed values are also called literals.  Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal. A constant is used to describe a numerical value, or a character string. Numerical constants may be expressed as real constants, integer constants or character constants. The constants are treated just like regular variables except that their values cannot be modified after their definition. You must initialize a constant when it is created. Defining Symbolic Constants: There are two simple ways in C++ to define constants: 1.     Using #define pre-processor: The pre-processor directive #define can create a constant by specifying its name an...

Constants

Image
  Constants:-              Constants in C++ refer to fixed values that do not change during the execution of a program. A constant is used to describe a numerical value, or a character string. Numerical constants may be expressed as real constants, integer constants or character constants. Numerical Constants:- A.     Integer Constants :- An integer constant refers to sequence digits. There are three types of integers, namely decimal, octal, and hexadecimal integer. Decimal integer consists of set of digits, 0 to 9.it is preceded by an optional – or + sign. E.g. 123, -345, 0, 685478, +14. Embedded spaces, commas, and non digit characters are not permitted between digits e.g. 15 570, $40, etc. An octal integer constant consists of any combination of digits from 0 to 7 with leading 0 e.g. 0373, 0, 0435, etc.  A sequence of digits preceded by 0x or 0X is considered as hexadecimal integer. They may also include alphabets A to...

Data Types in C++

Image
Data Types in C++:-             Data type is used to determine what type of value a variable or a constant can contain throughout the program. Whenever a variable is defined in C++, the compiler allocates some memory for that variable based on the data-type with which it is declared. Every data type requires a different amount of memory. C++ language is rich on its data types. The variety of data types available to allow the programmer to select the type appropriate to the needs of the application as well as the machine. In C++ language, different variables contain different data types e.g. Roll No contains an ‘integer’ value whereas percentage contains a 'float' value.             Data types are divided into three groups : A.     Primary (or Fundamental) data types. B.      Derived data types. C.     User-defined data ...

Tokens in C++

  Tokens in C++:- In a passage of a text, individual words and punctuation marks are called as tokens. Tokens act as building blocks of a program. Tokens in C++ are referred to as the smallest individual units in a program.   C++ programs written using these tokens and syntax of the language. These tokens are the basic entities of the language. Tokens are classified into six categories. 1.   Keywords 2.   Identifiers 3.   Constants 4.   Strings 5.   Operators 6.   Special Symbols Keywords:           Keywords are reserved words which have fixed meaning, and its meaning cannot be changed. Each keyword is meant to perform a specific function in a program. The meaning and working of these keywords are already known to the compiler. It is important to note that we cannot use C++ keywords for giving variable names. alignas alignof asm auto bool break ...