 # C++ Programming Code Examples

## C++ > Mathematics Code Examples

C++ Find Closest Pair of Points in an Array - Sort array of points according to X coordinate and Y coordinate. Find the distance between two points. And return the 'smallest distance' between 2 points. Find the 'distance' beween

C Program Compare two Text or Data files - Firstly Declare two file pointers for two files. Open 2 files in read mode. Now Inside while loop read both files character by character. Check both characters whether they're equal

C++ Language Codes Print Pascal Triangle - To print "Pascal Triangle" in C++, you have to enter the Number of Line. So to Print "Pascal Triangle", you have to use three For Loops as shown here in the C++ Programming samples

Finds First & Last Occurrence of Character - Take a string and a character as input. Store it in the array "str[]" & variable key respectively. Using for loop search for the variable key. If it is found then increment the variable count. If

C++ Program to Find Factorial of Number - First think what is the factorial of a number? How 'mathematically' it can be calculated. If you got this info then it will be very easier to make a C++ code logic to find the "Factorial".

C Program Code Finds Reverse of an Array - C program just print array in reversed order. It does not reverses the array. Here I am writing the first basic logic to reverse an array. It uses above approach to access array element in...

Checks the Connectivity of Directed Graph - Add Edge to connect "v" and "w". A recursive function to print BFS starting from s. Returns reverse ('or transpose') of this graph. Check if graph is connected. Print graph is connected.

Finds Factorial of Number using Recursion - Declare recursive function to find factorial of a number. First let us give a meaningful name to our function, say fact(). Factorial Function accepts an integer input whose factorial is to