# C Programming Code Examples

## C > Arrays and Matrices Code Examples

### Program to Find the Number of Elements in an Array

``` Program to Find the Number of Elements in an Array The formula that we are using to find the number of elements is common for all types of array. In this example, we have an array of double data type, however you can use the same logic for arrays of other data types like: int, float, long, char etc. #include <stdio.h> int main() { double arr[] = {13, 23, 33, 43, 53, 63}; int n; /* Calculating the size of the array with this formula. * n = sizeof(array_name) / sizeof(array_name[0]) * This is a universal formula to find number of elements in an array, which means it will work for arrays of all data types such as int, char, float etc. */ n = sizeof(arr) / sizeof(arr[0]); printf("Size of the array is: %d\n", n); return 0; } ```

C Program Displays the ATM Transactions - Firstly initialize the ATM pin and amount with some random number. Then take ATM pin as input. If the input pin is equal to initialized pin, then do the further operations. switch...

Program Code Find all Factors of Number - C program to input a number from user and find all factors of the given number using for loop. Factor of any number is whole number which exactly divides the number into whole

C Coding Checks the Character is Alphabet - How to check whether a character is alphabet or not in C programming. Every printable and nonprintable symbol is treated as a character and has an ASCII value. ASCII value is unique

C++ Program Implement Stack by Linked - C++ program, "using iteration", implements the list of elements removed from the stack in last in first out mode using a linked list. A linked list is an ordered set of data elements,

Program to Check if a Binary Tree is a BST - Returns true if the given tree is a BST and its values are >= min & <= max. Allocates a new node with the data and "NULL" left and right pointers. The Given Binary Tree is a "BST" or

Code Sum of Prime numbers between 1- n - C program to find sum of all prime numbers between 1 to n using for loop. Prime numbers are positive integers greater than 1 that has only two divisors 1 and the number itself. For

Program to Find the Biggest of 3 Numbers - This program takes the 3 numbers & finds the biggest among all. Take the three numbers as input and Check the First number if it Greater than other two. Repeat the step 2 for other 2

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