# C Programming Code Examples

## C > Mathematics Code Examples

### C Program to check if a number is palindrome or not

Allocates Sufficient Memory for an Array -
C Programming language code example to Allocates sufficient memory for an array of num objects of size size. Return: Returns a pointer to the first byte of the allocated...

C code to Check and Read Identity Matrix -
C program to read elements in a matrix and check whether matrix is an Identity matrix or not. Identity matrix is a special square matrix whose main diagonal elements is equal to 1

Printing 100 Ramanujan Numbers 2 Ways -
C++ Sample code Print first 100 "Ramanujan Numbers" by TWO WAYS 1st way is printing ramunajan numbers from RN taking RN from 0 to INFINITY & print first 100 numbers. 2nd

C Performs Quick Sort on A Set of Entries -
Perform Quick Sort on a set of entries from a file using recursion. The following C program, using recursion, performs 'quick sort'. A quick sort is a sorting algorithm with complexity of

In C++ Graph Coloring on Bipartite Graph -
The problem takes a bipartite graph as input and outputs colours of the each vertex after 'coloring the vertices'. The "Bipartite Graph" is a graph in which the set of vertices can be

C Program Codes Get nth Bit of a Number -
Program to input any number from user and check whether nth bit of the given number is set (1) or not (0). How to check whether nth bit of a given number is set or unset using...

Function strncpy Copies First n Characters -
If 'Length of str2' > n then it just copies first n characters of str2 into str1. If Length of str2 < n then it 'copies' all the characters of str2 into str1 & appends several 'terminator' chars('\0')

Replace First Occurrence of a Character in -
C Code replace first occurrence of a character with another in a string. Input the string from user, store it in some variable say 'str'. Input a character to replace, character new character