C++ Programming Code Examples
C++ > Mathematics Code Examples
C++ language Declare a Variable as Static
In the C++ Programming, The static keyword allows a variable to maintain its value among different function calls. If the value of a static variable changes when the variable has been
C Codes Calculates Prints the Value of nPr
In the following c program we are calculating the value of nPr based on the given values of n and r. nPr can also be represented as P(n,r). The formula of P(n, r) is: n! / (n - r)!. P(5, 2)=5!
C++ Program Merge Sort using Linked list
Split the Data into two equal half until we get at most one element in both half. Merge Both into one making sure the resulting 'Sequence' is sorted. Then 'recursively' split them, merge
Program Finds Sum of First and Last Digit
C Language Program to input a number and find sum of first and last digit of the number using for loop. Input a number. Find last digit. Find total number of digits - 1. Find first digit.
Represent Graphs Using Incidence Matrix
This algorithm takes the input of the number of vertex. For each pair of vertex ask whether they're connected or not. Print the incidence matrix. Function to print the incidence matrix
C Add Two Distances (in inch-feet) System
In this c program code, a structure Distance is defined. The structure has two members inch (a float) and feet (an integer). Two variables (distance1 and distance2) are created which...
Implementation for Linked List in the C++
Test if the list is logically empty. Return true if empty, false otherwise. Make the list logically "empty". Return an 'iterator' representing the header node. Return an iterator representing
C++ Finding Median of Two Sorted Arrays
Program find the 'median' of elements where elements are stored in 2 'different arrays'. We need to find 'combined' median of 2 different 'data set'. So it includes sorting of both arrays