C program to copy one array to another using pointers

Write a C program to copy one array elements to another array using pointers. How to copy array elements from one array to another array using pointers. Logic to copy one array to another array using pointers in C programming.

Example

Input

Input array1 elements: 10 -1 100 90 87 0 15 10 20 30

Output

Array1: 10 -1 100 90 87 0 15 10 20 30
Array2: 10 -1 100 90 87 0 15 10 20 30

Read more

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).

Read more

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.

Read more

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.

Read more

C program to right rotate an array

Write a C program to right rotate an array by n position. How to right rotate an array n times in C programming. Logic to rotate an array to right by n position in C program.

Right array rotation

Example

Input

Input 10 elements in array: 1 2 3 4 5 6 7 8 9 10
Input number of times to rotate: 3

Output

Array after right rotation: 8 9 10 1 2 3 4 5 6 7

Read more

C program to left rotate an array

Write a C program to left rotate an array by n position. How to rotate left rotate an array n times in C programming. Logic to rotate an array to left by n position in C program.

Left rotate an array

Example

Input

Input 10 elements in array: 1 2 3 4 5 6 7 8 9 10
Input number of times to rotate: 3

Output

Array after left rotation 3 times: 4 5 6 7 8 9 10 1 2 3

Read more

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

Read more

C program to count even and odd elements in array

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

Example

Input

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

Output

Total even elements: 4
Total odd elements: 5

Read more

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.

Read more