C# Array Exercises – C# Programming Example
Arrays

C# Array Exercises

Arrays in C# are a powerful way to store multiple elements of Similar type.

Below are the beginner as well as advanced level practice questions that involves C# Arrays concept. Although there are solutions given next to each of the question, we recommend that you come up with your own solution and only check the our solution to compare the approach.

Even though many of the below questions can easily be solved , it would be better to approach with your own solution to understand how arrays are implemented internally.

1) C# program to declare, initialize, input and print array elements

Write a C# program to declare, initialize, input elements in array and print array. How to input and display elements in an array using for loop in C# programming.

C# program to input and print array elements using loop.

Array uses an index for accessing an element. Array index starts from 0 to N-1 (where N is the number of elements in array).

Code:

 

2) C# program to print all negative elements in array

Write a C# program to input elements in array and print all negative elements. How to display all negative elements in array using loop in C# program. Logic to display all negative elements in a given array in C# programming.

Code:

 

3) C# program to find sum of array elements

Write a C# program to read elements in an array and find the sum of array elements. C# program to find sum of elements of the array. How to add elements of an array using for loop in C# programming. Logic to find sum of array elements in C# programming.

Code:

4) C# program to count negative elements in array

Write a C# program to input elements in array and count negative elements in array. C# program to find all negative elements in array. How to count negative elements in array using loop in C# programming. Logic to count total negative elements in an array in C# program.

Code:

 

5) C# program to find maximum and minimum element in array

Write a C# program to input elements in an array from user, find maximum and minimum element in array. C# program to find biggest and smallest elements in an array. Logic to find maximum and minimum element in array in C# programming.

Code:

 

6) C# program to find second largest number in array

Write a C# program to find largest and second largest element in an array. How to find second largest element in array in C# programming language. Logic to find second largest element in array in C# program.

Code:

 

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

Code:

8) C# program to insert an element in array

Write a C# program to insert element in array at specified position. C# program to insert element in array at given position. The program should also print an error message if the insert position is invalid. Logic to insert an element in array at given position in C# program.

Code:

9) C# program to delete element from an array

Write a C# program to delete element from array at specified position. How to remove element from array at given position in C# programming. Logic to remove element from any given position in array in C# program. The program should also print an error message if the delete position is invalid.

Code:

 

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

Code:

 

11) C# program to delete duplicate elements from array

Write a C# program to delete duplicate elements from array. How to remove duplicate elements from array in C# programming. After performing delete operation the array should only contain unique integer value. Logic to delete duplicate elements from array.

Code:

12) C# program to merge two sorted array

Write a C# program to input elements in two array and merge two array to third array. How to merge two array in C# programming. Logic to merge two sorted array to third array in C# program.

Code:

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

Code:

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

Code:

 

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

Code:

 

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

Code:

 

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

Code:

 

18) C# program to multiply two matrices

Write a C# program to read elements in two matrices and multiply them. Matrix multiplication program in C#. How to multiply matrices in C#. Logic to multiply two matrices in C# programming.

Code:

 

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: