Tag Archives: c array programs

C Program to Delete an Element from an Array

C Program to Delete an Element from an Array

In this tutorial, we will learn to create a C program that will delete the element of Array using C programming.

Prerequisites

Before starting with this tutorial we assume that you are best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • For loop in C Programming.

Delete the element of Array

As we all know array is a collection of similar data type elements. In an array, only one variable is declared which can store multiple values. First will take the number of elements of an array from the user. Then will take the elements from the user for the array. And at last, we will delete the array element by asking the user with the help of C Programming Language.

Algorithm:-

Program:-

To Delete an element from the array

Output:-

In the above program, we have first initialized the required variable.

  • x[] = it will hold the elements in an array.
  • n = it will hold the number of elements in an array.
  • i = it will hold the integer value to control the array.
  • loc = it will hold the location for delete element size of the array.

Taking input from the user in an array number of elements in the array

Taking input from the user in array elements in the array

Program Code

C Program to Insertion Sort Using Array

C Program to implement Insertion sort Algorithm

In this tutorial, we will learn to create a C program that will do insertion sort using C programming.

Prerequisites

Before starting with this tutorial we assume that you are best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • For loop in C Programming.
  • Creating and Using the user-defined function in C programming.

What is Insertion Sort?

In every programming language, the sorting of data is a very important factor.  In C Language. Many different techniques for sorting are available to work with but in this tutorial, we will focus on the Insertion Sort Technique.

In this technique, the work is done by inserting the smaller number to the first position. i.e. 

the first and second number is sorted if the number is big then it is moved to the right and if it is small the moves to the left.

 

Algorithm

 

 

Program For Insertion Sort

 

Output:-

In the above program, we have first declared and initialized a set of variables required in the program.

  • n = it will hold the size of the array.
  • x[]= it will hold the elements in an array.

Function to print array:-

Insertion sort function

Main function body

 

C Program to Access Elements of an Array Using Pointer

C Program to Access Elements of an Array Using Pointer

In this tutorial, we will learn to create a C program that will Access Elements of an Array Using Pointer using C programming.

Prerequisites

Before starting with this tutorial we assume that you are best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • For loop in C Programming.
  • Using pointer in C programming.

Access Elements of an Array Using Pointer:-

As we all know array is a collection of similar data type elements. In an array, only one variable is declared which can store multiple values. First will take the elements of an array from the user.  Then will pass the elements address to the pointer and the will print the elements of array /Access Elements of an Array Using Pointer with the help of C Programming Language.

Pointer is a variable that can store the address of another variable.

Algorithm:-

Program:-

Access Elements of an Array Using Pointer.

 

Output:-

The above program we have to first initialize the required variable.

 

  • array = it will hold the elements in an array.
  • i = it will hold the integer value to control array.

Creating Pointer.

  • *ptr = it will hold the address of elements in a array.

Taking input from the user in an array elements in array.

Printing using array.

C Program to Reverse an Array

C Program to Reverse an Array

In this tutorial, we will learn to create a C program that will reverse the element of Array using C programming.

Prerequisites

Before starting with this tutorial we assume that you are best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • For loop in C Programming.

The reverse of the array:-

As we all know array is a collection of similar data type elements. In an array, only one variable is declared which can store multiple values. First will take the number of elements of an array from the user. Then will take the elements from the user for the array. And at last, we will reverse the array using C Programming Language.

Algorithm:-

Program:-

To Reverse element from the array

Output:-

In the above program we have first initialized the required variable

n

  • arr = it will hold the elements in an array.
  • n = it will hold the number of  elements in an array.
  • i = it will hold the integer value to control the array.
  • size = it will hold the size of array.

Taking input from the user in an array number of elements in array

Taking input from the user in an array elements in array

Program Code

C Program to Find Minimum Element in Array

C Program to Find Minimum Element in Array

In this tutorial, we will learn to create a C program that will find the Minimum Element in Array using C programming.

Prerequisites

Before starting with this tutorial we assume that you are best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • For loop in C Programming.
  • Creating and Using the user-defined function in C programming.

The minimum value of array:-

As we all know array is a collection of similar data type elements. In an array, only one variable is declared which can store multiple values. The index value of the array start’s from “0” if the array is having size 5 i.e. a[5] = { 1, 2, 3, 4, 5 } values can be stored in that array. Now the a[0] = 1 , a[1] = 2, a[2] = 3, a[3] = 4, a[4] = 5. On the array, we can do many operations with the help of the c language.

We will find the minimum size element with the help of conditional statements.

Algorithm:-

Program:-

To find minimum value element from array

Output:-

In the above program we have first initialized the required variable

  • location = it will hold the location of array elements.
  • array[100] = it will hold the elements in an array.
  • i = it will hold the integer value to control the array.
  • size = it will hold the size of the array.

Printing output of the program to user

Program Code

C Program to Find Maximum Element in Array

C Program to Find Maximum Element in Array

In this tutorial, we will learn to create a C program that will find the maximum Element in Array using C programming.

Prerequisites

Before starting with this tutorial we assume that you are best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • For loop in C Programming.
  • Creating and Using the user-defined function in C programming.

The Maximum value of array:-

As we all know array is a collection of similar data type elements. In an array, only one variable is declared which can store multiple values. The index value of the array start’s from “0” if the array is having size 5 i.e. a[5] = { 1, 2, 3, 4, 5 } values can be stored in that array. Now the a[0] = 1 , a[1] = 2, a[2] = 3, a[3] = 4, a[4] = 5. On the array, we can do many operations with the help of the c language.

We will find the maximum size element with the help of conditional statements.

Algorithm:-

Program:-

To find the Maximum value element from the array

 

Output:-

In the above program, we have first initialized the required variable

  • arr[100] = it will hold the elements in an array.
  • i = it will hold the integer value to control the array.
  • no= it will hold the size of the array.

Printing output of the program to the user

Input Size.

Input elements of the array.

Calculating the maximum value.

C Program to Calculate Average Using Arrays

C Program to Find Average an Array

In this tutorial, we will learn to create a C program that will average the elements of Array using C programming.

Prerequisites

Before starting with this tutorial we assume that you are best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • For loop in C Programming.

Average of the array:-

As we all know array is a collection of similar data type elements. In an array, only one variable is declared which can store multiple values. First will take the number of elements of an array from the user. Then will take the elements from the user for the array. And at last, will total the values and divide them from the number of elements of the array to find the average using C Programming Language.

Algorithm:-

Program:-

To find the Average value element from the array

 

Output:-

In the above program we have first initialized the required variable

  • arr = it will hold the elements in an array.
  • n = it will hold the number of elements in an array.
  • i = it will hold the integer value to control the array.
  • sum= it will hold the sum of the array.
  • avg= it will hold the average of the array.

Taking input from the user in an array number of elements in the array.

Taking input from the user in array elements in the array.

Sum of the array.

Average of Array.

C Program For Merging Of Two Arrays

C Program to Merge Two Arrays

In this tutorial, we will learn to create a C program that will merge two different array the element of Array using C programming.

Prerequisites

Before starting with this tutorial we assume that you are best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • For loop in C Programming.

Merging of two arrays:-

As we all know array is a collection of similar data type elements. In array only one variable is declared which can store multiple values. First will take the number of elements of array1 from the user. Then will take the number of elements of array2 from the user. Then will take the elements from the user for the array1 and as well as for array 2.

And at last, will merge the values and of the different arrays into a single array using C Programming Language.

Algorithm:-

Program:-

To find Merge the two array element into single array

 

 

Output:-

The above program we have first initialize the required variable

  • a[] = it will hold the elements in a array1.
  • b[] = it will hold the elements in a array2.
  • c[] = it will hold the elements in a array3.
  • n1 = it will hold the number of  elements of array1.
  • n2 = it will hold the number of  elements of array2.
  • n3 = it will hold the number of  elements of array3.
  • i = it will hold the integer value to control array using for loop.

Taking input from the user for array1 as well as array2 and merging them.

Printing merged array.

C Program to Insert an Element in an Array

C Program to Insert an Element in an Array

In this tutorial, we will learn to create a C program that will Insert an Element in an Array using C programming.

Prerequisites

Before starting with this tutorial we assume that you are best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • For loop in C Programming.

Insert an Element of Array

As we all know array is a collection of similar data type elements. In an array, only one variable is declared which can store multiple values. First will take the number of elements of an array from the user. Then will take the elements from the user for the array. And at last, we will insert the array element by asking the user with the help of C Programming Language.

Algorithm:-

Program:-

To insert an element in the array

Output:-

In the above program, we have first initialized the required variable.

  • arrah[] = it will hold the elements in an array.
  • no = it will hold the number of elements in an array.
  • i = it will hold the integer value to control the array.
  • value = it will hold the value to be inserted.
  • position = it will hold the location for the insert element of the array.

Taking input from the user in an array number of elements in the array

Taking input from the user in array elements in the array

Insert location for elements.

 

inert value.

Printing output