# C++ Programming Code Examples

## C++ > Mathematics Code Examples

### Program to Swap Numbers in Cyclic Order Using Call by Reference

C++ An Object can be Passed to Functions -
An object can be passed to a function just like we pass structure to a function. Here in class A we have a "function disp()" in which we are passing the object of class A. Similarly we can

Finds out the Roots of Quadratic Equation -
C Program calculates the roots of a quadratic equation. First it finds Discriminant using the Formula: Disc = 'y*y-4*x*z'. There are 3 types of roots. They are complex, distinct and equal

A Templated Stack Data Structure sample -
Using Templates so that any type of data can be stored in stack without multiple defination of class. Contains "Location of Topmost data" pushed onto stack. Sets the top location to -1

C Returns a Pointer to the first occurrence -
C programming code sample about returns a pointer to the first occurrence of str2 in str1 or a null pointer if there str2 is not part of str1. It returns a null pointer if no match is...

Computes DFT Discrete Fourier Transform -
C++ Program to compute the 'coefficients' of the DFT (Discrete Fourier Transform) directly. In math, the discrete Fourier transform (DFT) converts finite list of equally spaced samples

C Build Binary Tree if Inorder or Postorder -
C Program to Build Binary Tree if inorder or postorder traversal as input. Create a new node. Create a balanced binary search tree. Insert a node in the tree. Create a node and

C Program sort directory entrys by filesize -
Code compare function for qsort. Add ONE element to the array. Allocate memory for ONE 'struct node'. Copy the data into the new element ( structure ). Qsort array of...

Remove Last Occurrence of Word in String -
Remove the 'last occurrence' of any word in a string using Loop in C Language. Input string from user, store it in some variable say string. Input word to be 'searched' from user, store it