Tag Archives: Array

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 a given array using recursion. How to find maximum and minimum elements in a given array using recursion in C programming. Using recursion find maximum or minimum elements in array in C program.

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. C program to read elements in an array and find sum of array elements using recursion. How to find sum of elements of array 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

C program to print elements of array using recursion

Write a C program to print all elements of any array using recursion. C program to read elements in an array from user and display all its elements using recursion. How to display all elements of an array using recursion. Logic to print elements of array using recursion in C program.

Example

Input

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

Output

Array elements: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

Continue reading C program to print elements of array using recursion

C program to sort even and odd elements of array separately

Write a C program to input elements in an array from user and sort all even and odd elements of the given array separately without using any other array. If minimum element of the array is even then all even elements should be placed in sorted order before odd elements otherwise all odd elements should be placed first. How to sort all even and odd elements of a given array separately in C programming.

Example

Input

Input size of array: 10
Input elements of array: 0 5 1 2 3 4 6 12 10 9

Output

Output in sorted order: 0 2 4 6 10 12 1 3 5 9

Continue reading C program to sort even and odd elements of array separately

C program to put even and odd elements of array in two separate array

Write a C program to input elements in an array and put all even and odd elements in two separate array. How to separate even and odd elements of a given array in two separate array containing only even or odd elements using C programming.

Example

Input

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

Output

Output even elements in array: 0 2 4 6 8
Output odd elements in array: 1 3 5 7 9

Continue reading C program to put even and odd elements of array in two separate array