This section covers C programming examples on Arrays. Every example program includes the description of the program, C code as well as output of the program. All examples are compiled and tested on a Linux system. These examples can be simple C programs or advanced C programs. So, they are suitable for any user (dummies, beginners or advanced users).
Here is the listing of C programming examples on Arrays.
1. C Examples on Mathematical Operations on an Array
An array is a sequence of data items of homogeneous value. The C programs in this section illustrates the addition operation being performed on an array. The addition operation is combined with different aspects like using pointers, using pointers as arguments, using Malloc and computing the sum of contiguous Subarray within a 1-D array of numbers which has the largest sum.
2. C Examples on Finding the Largest and Smallest Numbers in an Array
The C programs in this section evaluate the largest of the given numbers in an array, two of the largest numbers in a given array and second largest and smallest elements in an array.
C Program to Find the Largest Two Numbers in a given Array
C Program to Find the Second Largest & Smallest Elements in an Array
C Program to Find the Largest Number in an Array
3. C Examples on Inserting and Deleting Elements to and from an Array
The C programs in this section deals with insertion and deletion of elements in an array. It has programs to insert even and odd elements of an array into two separate arrays, to insert an element in a specified position in a given array, to remove the specified integer from an array and to cyclically permute the elements of the given array.
4. C Examples on Sort and Merge Operations on an Array
The C programs in this section deals with Sorting and Merging operations on an array. It has programs that demonstrate sorting of an array in ascending and descending order, sorting the names in alphabetical order, merging and sorting elements of two different arrays, merging the elements of 2 sorted arrays, sorting the numbers using Bubble Sort, splitting an array from the specified position and adding the first part to the end and a program to accept an array and perform the swapping operation on the elements using pointers.
5. C Examples on Search Operation on an Array
The C programs in this section deals with the search operations on an array. It has programs to read an array and search for an element in the input array, perform Binary Search on the elements of an array and to find the biggest number in an array of given numbers using recursion.
C Program to Read an Array and Search for an Element
C Program to accept Sorted Array and do Search using Binary Search
C Program to find the Biggest Number in an Array of Numbers using Recursion
6. C Examples on Queue and Stack Implementation of an Array
The C programs in this section deals with implementation of Queues and Stacks using an array. The programs also check for Overflow and Underflow conditions respectively.
C Program to Implement a Queue using an Array
C Program to Implement two Stacks using a Single Array & Check for Overflow & Underflow
7. C Examples on Printing the Elements of an Array
The C programs in this section deals with programs to generate Pascal Triangle, printing the number of odd and even numbers in an array, printing all the repeated numbers with frequency in an array and printing the kth element in an array.
C Program to Generate Pascal Triangle 1 D Array
C Program to Print the Number of Odd & Even Numbers in an Array
C Program to Print All the Repeated Numbers with Frequency in an Array
C Program to Print the kth Element in the Array
8. C Examples on Operations on Individual Elements of an Array
The C programs in this section deals with the individual elements of an array. It has programs to find the number of elements in the given array, testing array bounds while inserting elements into an array, printing the alternate elements, finding the odd elements of an array, incrementing the elements of an array and printing them, finding the missing elements and non-repeating elements in an array, segregating 0s and 1s on the left and the right side of an array and finding the 2 elements of an array such that the difference between them is the largest.
9. C Examples on Mathematical Functions and their Applications on Arrays
The C programs in this section deals with various aspects of mathematical functions and their applications on Arrays. It has programs to input a string and store the respective ASCII values in an integer array and thereby print the resultant array. It has programs on mathematical and statistical functions like Floor and Ceiling functions, Summation function, Union and Intersection operations, Median function, computing the Squares of the elements and testing if the given integer X appears more than N/2 times in a sorted array of N integers.