Category Archives: C Programs

C Programs

Count Frequency of each Element in an Array

C example to Count the frequency of each Element in an Array

In this tutorial, we will learn to create a C program that will Count the Frequency of each Element in an Array using C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the 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.
  • Arithmetic operations in C Programming.

Program to Count Frequency of each Element in an Array.

In this program, we will count the frequency of each element in the array. The frequency means the occurrence of the element in that array.

In this tutorial, we will first initialize the array. After that, we will find the length of the array. Then we will count the frequency of every element in the array. At last, we will print the frequency of each element to the user.

With the help of this program, we can Count the Frequency of each Element in an Array.

Program Code:-

 

Output:-

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

  • arr[] = it will hold the integer value.
  • i = it will hold the integer value.
  • j = it will hold the integer value.

Calculating the size of the array.

Program Logic Code.

Printing output of the program.

C example Count Positive and Negative Numbers in an Array

C example Count Positive and Negative Numbers in an Array

In this tutorial, we will learn to create a C program that will Count Positive and Negative Numbers in an Array using C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the 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.
  • Arithmetic operations in C Programming.

What is a positive number?

A number is said to be a positive number when that number is having a value greater than “0”. It means 1,2,3,4. 

What is a negative number?

A number is said to be a negative number when that number is having a value less than “0”. It means -1,-2,-3,-4. 

Program to Put Count Positive and Negative Numbers in an Array.

In this program, we will first take the input array size and the elements from the user. Then we will separate the positive and negative numbers from that array. After that, we will print the positive and negative Numbers Separately.

With the help of this program, we can Count Positive and Negative Numbers in an Array.

Program Code:-

 

Output:-

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

  • a[10] = it will hold the integer value.
  • i = it will hold the integer value.
  • Size = it will hold the integer value.

Input number of elements from the user.

Program Logic Code.

Printing output of the program.

C Program to Delete Duplicate Elements from an Array

C Program to Delete Duplicate Elements from an Array

In this tutorial, we will learn to create a C program that will Delete Duplicate Elements from an Array in C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the 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.
  • Conditional Statements in C programming.
  • Array in C programming.

Algorithm:-

Delete Duplicate Elements from an Array:-

In this program, we will first take the input size of the array. Then we will the elements of the array from the user. After that, we will remove the duplicate elements from the array. At last, we will print the array to the user with the removed elements.

With the help of this program, we can Delete Duplicate Elements from an Array.

Program Code:-

Output:-

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

  • i = it will hold the integer value.
  • j = it will hold the integer value.
  • k = it will hold the integer value.
  • arr[] = it will hold the integer value.

Taking the input size and the elements of the array.

Delete Duplicate Elements from an Array.

Printing the array.

C Program to Find Length or Size of an Array

C Program to Find Length or Size of an Array

In this tutorial, we will learn to create a C program that will Find the Length or Size of an Array in C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the 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.
  • Conditional Statements in C programming.
  • Array in C programming.

What is An array?

The array is a collection of similar data types. An array can store multiple values with different indexes in memory by using a single variable. The array can be both single and multidimensional.

Algorithm:-

Find Length or Size of an Array:-

As we all know, the 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 Find the Length or Size of an Array. And at last, we will print the Length or Size of an Array.

With the help of this program, we can print the Length or Size of an Array.

Program Code:-

Output:-

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

  • num = it will hold the integer value.
  • arr[] = it will hold the integer value.

Finding the length of the array.

Printing the length of the array.

C Program to Merge Two Arrays

C Program to Merge Two Arrays

In this tutorial, we will learn to create a C program that will Merge Two Arrays using C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the 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.
  • Arithmetic operations in C Programming.
  • Conditional Statements in the C Programming.

What is Merging?

The merging means is adding two or more arrays into one. Merging can be done with a simple c programming code.

Merging Two Arrays.

In this program, First, we will first take the size of the array from the user. Then we will take the elements of the array from the user. After that, we will add the array into a single array. Then we will print the merged array to the user.

With the help of this program, we can merge Two Arrays in an Array.

Program Code:-

 

Output:-

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

  • n1 = it will hold the integer value.
  • n2 = it will hold the integer value.
  • n3 = it will hold the integer value.

Taking the size of the array and the elements.

Program Code to Merge Two Arrays.

Printing output of the program.

C Program to Find Largest Number in an Array

C Program to Find The Largest Number in an Array

In this tutorial, we will learn to create a C program that will Find the Largest Number in an Array using C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the 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.
  • Arithmetic operations in C Programming.
  • Conditional Statements in the C Programming.

 Find the Largest Number in an Array.

In this program, First, we will first take the size of the array from the user. Then we will take the elements of the array from the user. After that, we will compare every element of the array and   Find the largest Number in that Array. Then we will print the largest element of the array to the user.

With the help of this program, we can be Find the Largest Number in an Array.

Program Code:-

Output:-

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

  • n = it will hold the integer value.
  • i = it will hold the integer value.
  • arr[100] = it will hold the integer value.

Taking the size of the array and the elements.

Program Code to find the largest elements in the array.

Printing output of the program.

C Program to Print Elements in an Array

C Program to Print Elements in an Array

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

Prerequisites

Before starting with this tutorial, we assume that you are the 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.
  • Arithmetic operations in C Programming.

Algorithm:-

Printing the Elements in an Array.

In this program, First, we will first take the size of the array from the user. Then we will take the elements of the array from the user. After that, we will use a for loop to print the elements of the array.

With the help of this program, we can be print the elements of the array.

Program Code:-

Output:-

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

  • no = it will hold the integer value.
  • i = it will hold the integer value.
  • arr[100] = it will hold the integer value.

Taking the size of the array and the elements.

Printing output of the program.

C Program to Find Largest and Smallest Number in an Array

C Program to Find Largest and Smallest Number in an Array

In this tutorial, we will learn to create a C program that will Find the Largest and Smallest Number in an Array using C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the 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.
  • Arithmetic operations in C Programming.
  • Conditional Statements in the C Programming.

 Find the Largest and the Smallest Number in an Array.

In this program, First, we will first take the size of the array from the user. Then we will take the elements of the array from the user. After that, we will compare every element of the array and   Find the largest and the Smallest Number in that Array. Then we will print the largest element and the smallest element of the array to the user.

With the help of this program, we can be Find the Smallest Number in an Array.

Program Code:-

Output:-

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

  • n = it will hold the integer value.
  • i = it will hold the integer value.
  • a[50] = it will hold the integer value.
  • sml = it will hold the integer value.
  • lrg = it will hold the integer value.

Taking the size of the array and the elements.

Program Code to find the largest & smallest elements in the array.

Printing output of the program.

C Program to Print Positive Numbers in an Array

C Program to Print Positive Numbers in an Array

In this tutorial, we will learn to create a C program that will Print Positive Numbers in an Array using C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the 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.
  • Arithmetic operations in C Programming.

What is a Positive number?

A number is said to be a Positive number when that number is having a value less than “0”. It means -1,-2,-3,-4. 

Program to Print Positive Numbers in an Array.

In this program, we will first take the input array size and the elements from the user. Then we will separate the Positive numbers from that array. After that, we will Put Positive Numbers in a Separate Array. At last, we will print the separated array containing Positive values.

With the help of this program, we can Print Positive Numbers in an Array.

Program Code:-

Output:-

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

  • arr = it will hold the integer value.
  • i = it will hold the integer value.
  • N = it will hold the integer value of the input.

Input number of elements from the user.

Program Logic Code.

Printing output of the program.

C Program to Put Positive and Negative Numbers in two Separate Arrays

C Program to Put Positive and Negative Numbers in two Separate Arrays

In this tutorial, we will learn to create a C program that will Put Positive and Negative Numbers in two Separate Arrays using C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the 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.
  • Arithmetic operations in C Programming.

What is a positive number?

A number is said to be a positive number when that number is having a value greater than “0”. It means 1,2,3,4. 

What is a negative number?

A number is said to be a negative number when that number is having a value less than “0”. It means -1,-2,-3,-4. 

Program to Put Positive and Negative Numbers in two Separate Arrays.

In this program, we will first take the input array size and the elements from the user. Then we will separate the positive and negative numbers from that array. After that, we will Put the positive and negative Numbers in Separate Arrays. At last, we will print the separated array containing both values.

With the help of this program, we can Print Positive & Negative Numbers in two Arrays.

Program Code:-

Output:-

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

  • a[10] = it will hold the integer value.
  • i = it will hold the integer value.
  • Size = it will hold the integer value.

Input number of elements from the user.

Program Logic Code.

Printing output of the program.

C Program to Print Negative Numbers in an Array

C Program to Print Negative Numbers in an Array

In this tutorial, we will learn to create a C program that will Print Negative Numbers in an Array using C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the 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.
  • Arithmetic operations in C Programming.

What is a negative number?

A number is said to be a negative number when that number is having a value less than “0”. It means -1,-2,-3,-4. 

What is An array?

The array is a collection of similar data types. An array can store multiple values with different indexes in memory by using a single variable. The array can be both single and multidimensional.

Program to Print Negative Numbers in an Array.

In this program, we will first take the input array size and the elements from the user. Then we will separate the negative numbers from that array. After that, we will Put negative Numbers in a Separate Array. At last, we will print the separated array containing negative values.

With the help of this program, we can Print Negative Numbers in an Array.

Program Code:-

Output:-

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

  • arr = it will hold the integer value.
  • i = it will hold the integer value.
  • N = it will hold the integer value of the input.

Input number of elements from the user.

Program Logic Code.

Printing output of the program.

C Program to Put Even and Odd Numbers in two Separate Arrays

C Program to Put Even and Odd Numbers in two Separate Arrays

In this tutorial, we will learn to create a C program that will Put Even and Odd Numbers in two Separate Arrays using C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the 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.
  • Arithmetic operations in C Programming.

What is Even and Odd number?

A number is said to be an even number when that number is divided by two into two equal whole numbers. A number is said to be an odd number when that number is divided by two into two, not equal entire numbers.

What is An array?

The array is a collection of similar data types. An array can store multiple values with different indexes in memory by using a single variable. The array can be both single and multidimensional.

Program to Put Even and Odd Numbers in two Separate Arrays.

In this program, we will first take the input array size and the elements from the user. Then we will separate the even and odd numbers from that array. After that, we will Put Even and Odd Numbers in two Separate Arrays. At last, we will print two separate arrays.

With the help of this program, we can Put Even and Odd Numbers in two Separate Arrays.

Program Code:-

Output:-

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

  • ARR= it will hold the integer value.
  • j = it will hold the integer value.
  • i = it will hold the integer value.
  • n = it will hold the integer value of the input.

Input number of elements from the user.

Program Logic Code.

Printing output of the program.