Tag Archives: Array

Pointers and Array in C – relationship and use

In C programming, pointers and array shares a very close relationship. Array is a data structure that hold finite sequential collection of similar type data. We use array to store a collection of similar type data together. To access and array element we use index. These index starts from 0 and goes up to N-1 (where N is size of the array).

Continue reading Pointers and Array in C – relationship and use

Multi-dimensional array in C – Declare, initialize and access

Multi-dimensional array is an array of array or more precisely collection of array. Unlike one-dimensional array, multi-dimensional array stores collection of array.

Let us revise the concept of dimension.

  • One-dimensional array : Collection of data/values.
  • Two-dimensional array : Collection of one-dimensional array.
  • Three-dimensional array : Collection of two-dimensional array.
  • N-dimensional array : Collection of N-1 dimensional array.

Continue reading Multi-dimensional array in C – Declare, initialize and access

Arrays in C – Declare, initialize and access

Array is a data structure that hold finite sequential collection of homogeneous data.

To make it simple let's break the words.

  • Array is a collection - Array is a container that can hold a collection of data.
  • Array is finite - The collection of data in array is always finite, which is determined prior to its use.
  • Array is sequential - Array stores collection of data sequentially in memory.
  • Array contains homogeneous data - The collection of data in array must share a same data type.

Continue reading Arrays in C – Declare, initialize and access

C program to count frequency of digits in an integer

Write a C program to count frequency of digits in a given number. How to find frequency of digits in a given number using loop in C programming. Logic to find total occurrences of each digits in a given number in C program.

Example

Input

Input any number: 116540

Output

Frequency of 0 = 1 
Frequency of 1 = 2 
Frequency of 2 = 0 
Frequency of 3 = 0 
Frequency of 4 = 1 
Frequency of 5 = 1 
Frequency of 6 = 1 
Frequency of 7 = 0 
Frequency of 8 = 0 
Frequency of 9 = 0

Continue reading C program to count frequency of digits in an integer

C program to count even and odd elements in an array

Write a C program to read elements in an array from user and count total number of even and odd elements in the given array. How to find total number of even and odd elements in a given array using C programming. Logic to find even and odd elements in an array.

Example

Input

Input array: 1 2 3 4 5 6 7 8 9

Output

Total even elements: 4
Total odd elements: 5

Continue reading C program to count even and odd elements in an array

C program to remove all repeated characters in a string

Write a C program to remove all repeated characters in a string using loops. How to remove all duplicate characters from a string using for loop in C programming. Program to find and remove all duplicate characters in a string. Logic to remove all repeated character from string in C program.

Example

Input

Input string: Programming in C.

Output

String after removing duplicate characters: Progamin C.

Continue reading C program to remove all repeated characters in a string

C program to find maximum and minimum elements in array using recursion

Write a C program to find maximum and minimum elements in an array using recursion. How to find maximum and minimum element in an array using recursion in C programming. Logic to find find maximum or minimum elements in array in C programming.

Example

Input

Size of array: 10
Elements in array: 5, 1, 6, 10, 2, 3, 6, 50, -7, 4

Output

Maximum element = 50
Minimum element = -7

Continue reading C program to find maximum and minimum elements in array using recursion

C program to find sum of array elements using recursion

Write a C program to find sum of array elements using recursion. How to find sum of array elements using recursive function in C programming. Logic to find sum of array elements using recursion in C program.

Example

Input

Input size of array: 10
Input array elements: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

Output

Sum of array: 55

Continue reading C program to find sum of array elements using recursion