Category Archives: Library

16. Passing Arrays to Functions

C++ does not allow passing an entire array as an argument to a function. However, You can pass a pointer to an array by specifying the array’s name without an index. If you want to pass a single-dimension array as an argument in a function, you would have to declare function formal parameter in one… Read More »

15. Pointer to an Array

It is most likely that you would not understand this chapter until you go through the chapter related to C++ Pointers. So assuming you have bit understanding on pointers in C++, let us start: An array name is a constant pointer to the first element of the array. Therefore, in the declaration − double balance[50];… Read More »

14. Multi-dimensional Arrays

C++ allows multidimensional arrays. Here is the general form of a multidimensional array declaration− type name[size1][size2]…[sizeN]; For example, the following declaration creates a three dimensional 5 . 10 . 4 integer array − int threedim[5][10][4]; Two-Dimensional Arrays The simplest form of the multidimensional array is the two-dimensional array. A two-dimensional array is, in essence, a… Read More »

13. Arrays

C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type. Instead of declaring individual variables, such as… Read More »

12. Memory management

What is Memory Management? Memory management is a process of managing computer memory, assigning the memory space to the programs to improve the overall system performance. Why is memory management required? As we know that arrays store homogeneous data, so most of the time, memory is allocated to the array at the declaration time. Sometimes… Read More »

11. Pointers

C++ pointers are easy and fun to learn. Some C++ tasks are performed more easily with pointers, and other C++ tasks, such as dynamic memory allocation, cannot be performed without them. What are Pointers? A pointer is a variable whose value is the address of another variable. Like any variable or constant, you must declare a pointer… Read More »

10. LOOPS

There may be a situation when you need to execute a block of code several times. In general, statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on. Programming languages provide various control structures that allow for more complicated execution paths. A loop statement allows… Read More »

09. C++ switch statement

A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case. Syntax The syntax for a switch statement in C++ is as follows − switch(expression) { case constant-expression : statement(s); break; //optional case constant-expression : statement(s); break;… Read More »

08. AND, OR & NOT

Logical Operators There are following logical operators supported by C++ language. Logical operators are used to determine the logic between variables or values: Operator Name Description Example &&  Logical and Returns true if both statements are true x < 5 &&  x < 10 ||  Logical or Returns true if one of the statements is… Read More »

07. C++ Conditions and If Statements

C++ supports the usual logical conditions from mathematics: Less than: a < b Less than or equal to: a <= b Greater than: a > b Greater than or equal to: a >= b Equal to a == b Not Equal to: a != b You can use these conditions to perform different actions for different decisions. C++ has the following… Read More »