C++ Tutorials

1. Calculating total based on the given quantity and price in C++

By: Jeffrey : 2012-03-16

Description: This simple C++ program shows how to calculate total based on the given quantity and price.


2. Sorting an array of Strings in C++

By: Ignatius : 2012-03-16

Description: This simple C++ program sorts the elements of an integer array and prints them.


3. Matrix using nested for loops in C++

By: Ignatius : 2012-03-16

Description: This simple C++ program illustrates the use of three nested for loops. The program multiplies matrix x and y and stores the resulting matrix product xy in matrix z. Both x and y must be compatible for multiplication that means, the number of columns of x must be equal to the number of rows of y


4. Compute the square root of the sum of the squares of an array in C++

By: Ignatius : 2012-03-16

Description: This simple C++ program computes the square root of the sum of the squares of all the positive elements in array named x. It uses the header file math.h since it contains the mathematical functions pow() (for taking the power of a number) and sqrt() (for taking the square root of a number)


5. Calculate average using Two-Dimensional Array in C++

By: Ignatius : 2012-03-16

Description: This simple C++ program illustrates the use of two-dimensional arrays. This program calculates the average of all the elements in the integer array named x. For this, the program uses two nested for loops. The outer loop with index i provides the row subscript. The nested for loops therefore accesses each element of the array and the inner loop with index j provides the column subscript.


6. Two-Dimensional Array Manipulation in C++

By: Ignatius : 2012-03-16

Description: This simple C++ program shows how to manipulate a two dimensional array. In this case it will traverse through the array and print its contents.


7. Compiling and Linking Multiple Source Files in C++

By: B. Lippman : 2011-03-18

Description: To produce an executable file, we must tell the compiler not only where to find our main function but also where to find the definition of the member functions defined by the Sales_item class. Let's assume that we have two files: main.cc, which contains the definition of main, and Sales_item.cc, which contains the Sales_item member functions. We might compile these files as follows:


8. Enumerations in C++

By: Stanley B. : 2011-03-12

Description: Often we need to define a set of alternative values for some attribute. A file, for example, might be open in one of three states: input, output, and append. One way to keep track of these state values might be to associate a unique constant number with each. We might write the following:


9. Concatenated String Literals in C++

By: Stanley B. : 2011-02-19

Description: Two string literals (or two wide string literals) that appear adjacent to one another and separated only by spaces, tabs, or newlines are concatenated into a single new string literal. This usage makes it easy to write long literals across separate lines:


10. Program to add two numbers in C++

By: Stanley B. : 2011-02-19

Description: Using the IO library, we can extend our main program to ask the user to give us two numbers and then print their sum: