# Array

## C/C++ Program to find the sum of adjacent pairs in an array

Write a program to find the sum of adjacent pairs in an array in C/C++. Example, Input 1 2 2 3 4 5 Output 3 4 5 7 9 The program is very simple. We traverse each element of the array (except for the first element) and print the sum of the current element and …

## Program to swap first half with last half in an array

Write a program to swap first half with last half in an array. Example, Input { 1, 2, 3, 4, 5, 6, 7, 8 } Output { 5, 6, 7, 8, 1, 2, 3, 4 } Input { 12, 13, 14, 15, 16 } Output { 15, 16, 14, 12, 13 } Step Let arr …

## C Program to Perform Matrix Multiplication using Pointers

In this post, we will study how to perform matrix multiplication using pointers in two ways – without using recursion and using recursion.

## Sort Two Dimensional (2D) array

In this article, we will learn different ways to sort a two dimensional (2D) array. Sort all elements of a 2D Array In this section, we discuss how to sort all the elements of the 2D array such that all the elements in a row are in increasing order and the first element of any …

## Minimum number of comparisons to find the minimum and maximum

In this article, we will learn how to find the minimum number of comparisons to find the minimum and maximum elements of an array and derive a general formula for it. The formula for the minimum number of comparisons to find the minimum and the maximum elements is ( 3n / 2 ) – 2 …

## Initialize 2D Array C++ To Zero

Initialize 2D array C++ to zero. Set all elements of a 2D array to 0 using memset. How to initialize a 2D array with all zeros in C++?

## Merge Two Sorted Arrays using Recursion

Merge Two Sorted Arrays into one sorted array using Recursion. Merging sorted arrays using recursion is similar to merging using a loop.

## How to Declare a Matrix in C++

In this article, we will discuss how to declare Matrix in C++. We will use array to represent Matrix. A Matrix is nothing but a 2-D array. We can declare Matrix in C++ in 2 ways Static Allocation Dynamic Allocation Declare a Matrix in C++ (Static Allocation) Static Allocation means memory is fixed. The memory …

## C Program to Subtract 2 Matrices

Write a Program to Subtract 2 Matrices in C. Program for the subtraction of two Matrices in C using recursion and without using recursion.

## Difference between Array and Linked List

The main difference between array and the linked list is that array occupies contiguous memory whereas linked list memory is scattered.