# C++ Programming Code Examples

## C++ > Mathematics Code Examples

### C++ Program to Find GCD

Code Prints the Factorial of given Number - C code Print the 'Factorial' of a given number. A factorial is product of all the numbers from 1 to n, where n is the 'specified number'. This C program find the product of all the number

C++ Template to Gets Maximum Number - Templates are a feature of the C++ language that allows functions and classes to operate with generic types. A "simple C++ template" behaves same as normal function except the

C++ Codings Find the Maximum Subarray - Implement the 'naive method' to find the sub array having a maximum sum. The worst case time 'Complexity' of the algorithm is 'O(n*n)'. Take the input of the 'integer array'. Compare

Program to find Maximum using var-args - Here, I will embed the logic to find maximum within a function. Lets define function to find maximum. 1 - give a meaningful name to our function. Say "max()" function is used to find

Triangle is Equilateral, Scalene or Isosceles - C program input sides of a triangle and check whether a Triangle is Equilateral, Scalene or Isosceles triangle using if else. Triangle is said Equilateral Triangle, if all its sides are equal. If

C Program to Open, Read & Close the File - C various file opening modes: File is opened using fopen() c function, while opening you can use any of the following mode as per the requirement. Mode "r": It is a read only mode,

Checks Given Graph is Strongly Connected - If there exists "Multiple Strongly Connected" component, graph is not strongly connected, it is otherwise. Implementation of Kosaraju's Algorithm to "Print all SCCs". Fills Stack with

Program to Accept the Height of a Person - Take the height of a person as input and store it in the variable height. If the variable height is lesser than 150 cm, then print the output as "Dwarf". If the variable height is lesser than...