Show how to explicitly allocate and deallocate blocks of memory in your language. Show access to different types of memory (i.e., heap, stack, shared, foreign) if applicable. While the C […]

Continue Reading## C++: Write CSV File

void write_csv_file(double A[], int length, string file_name) //Function that prints array A to a *.csv file { ofstream output(file_name); for(int i = 0; i < length; i++) { output << […]

Continue Reading## C++: Map Range

Given two ranges, [a1,a2] and [b1,b2]; then a value s in range [a1,a2] is linearly mapped to a value t in range [b1,b2] when: The task is to write a […]

Continue Reading## C Programming Tips

C is one of the most important and widely used of all programming languages. It is a powerful language that can be used not only to build general-purpose applications but […]

Continue Reading## C++ Graphs

## C++: Radix Sort

// C++ LSD Radix Sort example, queue implementation #include <iostream.h> #include <cstdlib.h> #include <ctime.h> using std::cout; // Remove this line for older C++ compilers typedef struct slist_ { int val; […]

Continue Reading## C++: Happy Numbers

From Wikipedia, the free encyclopedia: A happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its […]

Continue Reading## C++: Greatest Common Denominator

int Find_Greatest_Common_Denominator(int x, int y) //Function that finds the Greatest Common Denominator (“GCD”) between 2 integers { int a; if(x==0) cout << y << endl; if(y==0) cout << x << […]

Continue Reading## C++: Hostname

Find the name of the host on which the routine is running. #include <stdlib.h> #include <stdio.h> #include <limits.h> #include <unistd.h> int main(void) { char name[_POSIX_HOST_NAME_MAX + 1]; return gethostname(name, sizeof […]

Continue Reading## C++: Multiplicative Digital Root

The multiplicative digital root (MDR) and multiplicative persistence (MP) of a number, n, is calculated rather like the Digital root except digits are multiplied instead of being added: Set m […]

Continue Reading