C program to subtract two matrices

Write a C program to read elements in two matrices and find the difference of two matrices. Program to subtract two matrices in C. Logic to subtract two matrices in C programming.

Example

Input

Input elements in 3x3 matrix1:
1 2 3
4 5 6
7 8 9

Input elements in 3x3 matrix2:
9 8 7
6 5 4
3 2 1

Output

Difference of both matrices =
-8 -6 -4
-2  0  2
4  6  8

Read more

C program to add two matrices

Write a C program to read elements in two matrices and add elements of both matrices. C program for addition of two matrix. Matrix addition program in C. Logic to add two matrix in C programming.

Example

Input

Input elements in 3x3 matrix1: 
1 2 3
4 5 6
7 8 9
Input elements in 3x3 matrix2:
9 8 7
6 5 4
3 2 1

Output

Sum of both matrix =
10 10 10
10 10 10
10 10 10

Read more

C program to print all unique elements in array

Write a C program to input elements in array and print all unique elements in array. How to find unique elements in array in C programming. Logic to find unique elements in array in C program.

Array unique elements

Example

Input

Input array elements: 1, 2, 3, 5, 1, 5, 20, 2, 12, 10

Output

All unique elements in the array are: 3, 20, 12, 10

Read more

C program to count total number of notes in given amount

Write a C program to input amount from user and print minimum number of notes (Rs. 500, 100, 50, 20, 10, 5, 2, 1) required for the amount. How to the minimum number of notes required for the given amount in C programming. Program to find minimum number of notes required for the given denomination. Logic to find minimum number of denomination for a given amount in C program.

Example
Input

Input amount: 575

Output

Total number of notes: 
500: 1
100: 0
50: 1
20: 1
10: 0
5: 1
2: 0
1: 0

Read more

Array and Matrix programming exercises and solutions in C

Array is a linear data structure that hold finite sequential collection of homogeneous data. We can store a collection of values in an array.

Array uses an integer value index to access a specific element. Index starts from 0 and goes till N-1 (where N is the size of array).

Read more

C program to find power of a number using for loop

Write a C program to find power of a number using for loop. How to find power of a number without using built in library functions in C program. Logic to find power of any number without using pow() function in C programming.

Example

Input

Input base: 2
Input exponent: 5

Output

2 ^ 5 = 32

Read more

C program to sort array in ascending or descending order

Write a C program to input elements in array and sort array elements in ascending or descending order. How to sort array in ascending order in C programming. Logic to sort array in ascending or descending order.

Example

Input

Input size of array: 10
Input array elements: 20, 2, 10, 6, 52, 31, 0, 45, 79, 40

Output

Array sorted in ascending order: 0, 2, 6, 10, 20, 31, 40, 45, 52, 79

Read more

C program to search element in an array

Write a C program to input elements in array and search whether an element exists in array or not. How to search element in array linearly in C programming. Logic to search element in array sequentially in C program.

Example

Input

Input size of array: 10
Input elements in array: 10, 12, 20, 25, 13, 10, 9, 40, 60, 5

Output

Element to search is: 25
Element found at index 3

Read more

C program to count frequency of each element in an array

Write a C program to input elements in array and find frequency of each element in array. How to count occurrence of each element in array in C programming using loop. Logic to count frequency of each element in array in C program.

Array frequency

Example

Input

Input array elements: 5, 10, 2, 5, 50, 5, 10, 1, 2, 2

Output

Frequency of 5 = 3
Frequency of 10 = 2
Frequency of 2 = 3
Frequency of 50 = 1
Frequency of 1 = 1

Read more

C program to find reverse of array

Write a C program to input elements in array and find reverse of array. How to find reverse of array in C programming. Logic to find reverse of array in C program.

Example

Input

Input array elements: 10, 5, 16, 35, 500

Output

Array elements after reverse: 500, 35, 16, 5, 10

Read more