Examples C++

Description Code
Introduction
First C++ program that says hello hello.cpp
Test arithmetic operations TestArithmetics.cpp
Sum from 1 to an upperbound using a while-loop SumNumbers.cpp
Sum the odd and even numbers from 1 to an upperbound SumOddEven.cpp
Convert temperature between Celsius and Fahrenheit ConvertTemperature.cpp
Testing type cast TestCastingAverage.cpp
Print Size of Fundamental Types SizeofTypes.cpp
Test integer limits in <climits> header TestLimits.cpp
Testing Primitive Types TestLiteral.cpp
Testing mix-type arithmetic operations TestMixTypeOp.cpp
Test Arithmetic Overflow/Underflow TestOverflow.cpp
Test on increment (++) and decrement (--) Operator TestIncDec.cpp
Test implicit type casting TestImplicitTypeCast.cpp
Testing Explicit Type Cast Average1to100.cpp
Test Type Casting TestTypeCast.cpp
Sum from 1 to a given upperbound and average SumNumbers.cpp
Statistics of positive integers StatNumbers.cpp
List non-prime from 1 to an upperbound NonPrimeList.cpp
List primes from 1 to an upperbound PrimeListWithBreak.cpp
List primes from 1 to an upperbound use break PrimeList.cpp
A mystery series Mystery.cpp
Print square pattern PrintSquarePattern.cpp
Testing string class input and output TestStringIO.cpp
Example on C++ string function TestStringOp.cpp
Test Formatting Output TestFormattedOutput.cpp
Test Formatting Input TestFormattedInput.cpp
Test local array initialization TestArrayInit.cpp
Mean and standard deviation in an array MeanStdArray.cpp
Testing For-each loop TestForEach.cpp
Test Multi-dimensional Array Test2DArray.cpp
Test C-string TestCString.cpp
Functions
Test Function TestFunction.cpp
Testing max function TestMaxFunction.cpp
Test Boolean function BooleanfunctionTest.cpp
Test Function default arguments functionDefaultArgument.cpp
Test Function Overloading FunctionOverloading.cpp
Function to compute the sum of an array SumArray.cpp
Types passed by value into Function TestPassByValue.cpp
Function to increment each element of an array IncrementArray.cpp
Linear Search an array for the given key LinearSearch.cpp
Test Pass-by-reference parameter TestPassByReference.cpp
Test Random Number Generation TestRand.cpp
Test rand() distribution (throwing a die) TestRandomDie.cpp
Test File I/O (Read and write files) TestFileIO.cpp
Example Namespace NamespaceEx.cpp
Struct:
Testing struct TestStruct.cpp
Testing struct inside struct TestStruct1.cpp
Testing struct (Person) TestStructPerson.cpp
Test Inline Function TestInlineFunction.cpp
Test #define macro TestMacro.cpp
Test Ellipses TestEllipses.cpp
Test Scope Resolution Operator TestScopeResolutionOperator.cpp
Command line arguments
Write command line arguments arg_comm.cpp
Command line calculator (int): num1 num2 operator Arithmetic.cpp
Pointers:
Test pointer declaration and initialization TestPointerInit.cpp
Test reference declaration and initialization TestReferenceDeclaration.cpp
References vs. Pointers TestReferenceVsPointer.cpp
Pass-by-value into function TestPassByValue1.cpp
Pass-by-reference using pointer TestPassByPointer.cpp
Pass-by-reference using reference TestPassByReference1.cpp
Test Function const and non-const parameter FuncationConstParameter.cpp
Passing back return value using reference TestPassByReferenceReturn.cpp
Test passing the result TestPassResultLocal.cpp
Test passing the result TestPassResultNew.cpp
Dynamically allocate global pointers TestDynamicAllocation.cpp
Test dynamic allocation of array TestDynamicArray.cpp
Pointer and Array TestPointerArray.cpp
Passing array in/out function TestArrayPassing.cpp
Passing array in/out function using pointer TestArrayPassingPointer.cpp
Test sizeof array TestSizeofArray.cpp
Function to compute the sum of a range of an array SumArrayRange.cpp
Testing C-string TestCString1.cpp
Function to count the occurrence of a char in a string FCountChar.cpp
Test Function Pointers TestFunctionPointer.cpp
Search an array for a key using Binary Search BinarySearch.cpp
Lagrange Interpolation:
\begin{align} (x_{0}, y_{0}), ..., (x_{k}, y_{k}) \end{align} \begin{align} L(x) = \sum_{j=0}^{k} \prod_{i = 0, i\neq j}^{k} y_{j}\frac{x - x_{i}}{x_{j} - x_{i}} \end{align}
- arrays lagrangearr.cpp
- dynamic memory lagrangep.cpp
- dynamic memory and struct lagrangeps.cpp
Sorting an array:
using Bubble Sort BubbleSort.cpp
using Insertion Sort InsertionSort.cpp
using Selection Sort SelectionSort.cpp
using Merge Sort MergeSort.cpp
using Merge Sort with bottom-up interactive algorithm MergeSortInteractive.cpp
using Quick Sort QuickSort.cpp
Bucket Sort (Radix Sort) BucketSort.cpp
Files:
Testing Simple File IO TestSimpleFileIO.cpp
Testing Binary File IO TestBinaryFileIO.cpp
Strings:
Strings stringcpp.cpp
Strings 1 stringcpp1.cpp
Guess a secret word WordGuess.cpp
Numerical methods:
Calculation of derivative derivada.cpp
Calculation of derivative (central method) derivada1.cpp
Calculation of derivative (trick method) derivada2.cpp
Calculation of integral (trapezoidal method) integraltrapez.cpp
Calculation of integral (simpson method) integralsimpson.cpp
Calculation of integral (adaptive method) integraladap.cpp
Calculation of integral (adaptive simpson method) integralsimpsonadap.cpp
Calculation of integral (gauss-legendre method) integralgausslegbreak.cpp
Calculation of integral (gauss-legendre method break) integralgausslegbreak.cpp
Calculation of integral (montecarlo method) montecarlo_integ.cpp
Calculation of integral (euler method) euler.cpp
Root calculation (Newton method) newton_root.cpp
Root calculation (Newton + Secant method) newtondernum_root.cpp
Ordinary Differential Equation (ODE) solution Runge Kutta 4 method rk4.cpp
Matrices:
Dynamically Allocate Memory for 2D Array (*) array2dp.cpp
Dynamically Allocate Memory for 2D Array (**) array2dpp.cpp
Dynamically Allocate Memory for 3D Array array3dppp.cpp
Matrix operations (pointers) operac_matric.cpp
Image smoothing (pointers) suavizado.cpp
Image Histogram (pointers) histo.cpp
Matrix operations (vector) matrix_vector.cpp
Pi calculation:
 Liu-Hui Method pi_Liu_Hui_meth.cpp
 Liebniz Method pi_Liebniz_meth.cpp
Recursion, backtracking:
 Greatest common divisor (GCD) gcd.cpp
 Change base cambiabase.cpp
 Factorial factorial.cpp
 Tower of Hanoi thanoi.cpp
 Branch and Bound b_b.cpp
 Knight's tour knight.cpp
 Eight queens reinas.cpp
 Sudoku sudoku.cpp, Data sudoku