Category Archives: Array

Program for Shell Sort in C and C++

Here you will get program for shell sort in C and C++. Shell short is an improved and efficient version of insertion sort. In this algorithm we sort the pair of elements that are far apart by gap h. The process is repeated by reducing h until it becomes 1. Program for Shell Sort in… Read More »

C/C++ Program for Union of Two Arrays

Here you will get C/C++ program to find union of two arrays. For example: First array: {1, 3, 7, 9} Second array: {1, 4, 6} Union: {1, 3, 4, 7, 6, 9}   C/C++ Program for Union of Two Arrays Union of Two Sorted Arrays If two arrays are sorted then their union can be… Read More »

C/C++ Program to Remove Duplicate Elements From Array

Here you will get C and C++ program to remove duplicate elements from array.   For example: Given Array: 5 8 9 5 12 9 New Array: 5 8 9 12 In this program I have compared each element with all other elements. If the element is equal to any other element in the array then… Read More »

Anagram in C

Here is the program for anagram in c.   Two strings are said to be anagrams if by rearranging the characters of any one string will make both strings equal.   Example: “adssfa” and “dsasfa” are anagrams “adsfa” and “sdfac” are not anagrams How to Check two Strings are Anagrams or not? So what we will… Read More »

Insertion Sort in C & C++ – Program & Algorithm

In this tutorial I will explain about algorithm for insertion sort in C and C++ using program example. The insertion sort inserts each element in proper place. The strategy behind the insertion sort is similar to the process of sorting a pack of cards. You can take a card, move it to its location in sequence and move… Read More »

Selection Sort in C & C++ – Program & Algorithm

In this tutorial I will explain about algorithm for selection sort in C and C++ using program example.    One of the simplest techniques is a selection sort. As the name suggests, selection sort is the selection of an element and keeping it in sorted order. In selection sort, the strategy is to find the smallest number… Read More »

C Program for Finding Transpose of a Sparse Matrix

Here you will get C program to find transpose of a sparse matrix. Transpose of a matrix is obtained by interchanging rows and columns. In another way, we can say that element in the i, j position gets put in the j, i position. Transpose  of the matrix B1 is obtained as B2 by inserting… Read More »

Linear Search in C

Here you will find program for linear search in C. Linear search is the simplest searching algorithm which is sometimes known as sequential search. In this algorithm each element of array is compared with the targeted element sequentially. Linear Search in C

  Output  How many elements?4 Enter array elements: 6 8 9 1… Read More »

Transpose of Matrix in C

Here is the program for transpose of matrix in C. We first read a matrix of size mxn and then find its transpose by just interchanging the rows and columns i.e. rows become columns and columns become rows. Transpose of Matrix in C

  Output How many rows?3 How many columns?3 Enter the matrix:… Read More »

C Program to Find Largest and Smallest Element in Array

Here is the C program to find the largest and smallest element in a one dimensional (1-D) array.

  Output How many elements:5 Enter the Array:1 8 12 4 6 The largest element is 12 The smallest element is 1

Matrix Addition in C

Here you will find program for matrix addition in C. Two matrix can be added only when number of rows and columns of first matrix is equal to number of rows of columns of second matrix. Matrix Addition in C

  Output How many rows and columns?3 3 Enter first matrix: 2 6 9… Read More »