Programming examples of Array in C#

example
In this chapter you will learn about some programming examples of array in C#.

Qu 1:Write a program of sorting an array. Declare single dimensional array and accept 5 integer values from the user. Then sort the input in ascending order and display output.
Answer

Output

Enter number:      56
Enter number:      34
Enter number:      23
Enter number:      1
Enter number:      76Elements of array are:56      34      23      1      76

Elements of array are:

1       23      34      56      76
__




  • Qu2: Write a program to create two multidimensional arrays of same size. Accept value from user and store them in first array. Now copy all the elements of first array are second array and print output.
    Answer

    Output

    Enter your option <1-7> for days. 1 for Monday: 9
    Invalid option. Please try againEnter your option <1-7> for days. 1 for Monday: 2
    Tuesday
    __

     

    Summary

    In this chapter you studied some programming examples of array. In next chapter you will get some programming exercises of array.

     

    More Examples

     


    4 thoughts on “Programming examples of Array in C#”

    1. 1. Write a program to sort one dimentional array in ascending order using static method.
      2. Write a program to sort one dimentional array in ascending order using non static method.
      3. Write a program to sort one dimentional array in desending order static class array method.
      4. write a program to add the diagonal of two-dimentional array.
      5. Write a program to convert days into years and weeks.
      6. Write a program to determine the roots of a quartic equation.
      7. Write a program to determine the number of words and characters in a sentence.
      8. Write a program to print the biggest of three integers using the ‘FOR’ Loop the program end if three numbers equal zero.
      9. Write a program to print the quotient and remainder of two integers.
      10. Write a program to determine whether an integer is prime or composite.
      11. Write a program that enables the user to enter the sale value and find the agent’s commission for that sale.
      12. Write a program to print the final velocity after taking in the velocity, acceleration and the time as input from the user using non static method.
      a. V= u + a.t
      13. Write a C# program to calculate sum of upper triangle elements of 2-D array.
      14. Write a C# program to find addition of lower triangle elements of 2-D array.
      15. Create a class with Name Base. Create another class with the name Derived. Inherit the Base class into Derived Class.
      16. Implement the following things in the program for both classes.
      i. Write default Constructors
      ii. Call base class method called print() inside Derived Class
      iii. Create the instance of Derived Class in the Main() to access the methods.
      17. Write a program to find the average tempratures of 7-days ( week) using 1-D array and foreach loop.
      18. Write a program to initialize the 7-days temprature into 1-D array using constuctor and calculate the smallest value of temprature.

    Leave a Reply

    Your email address will not be published. Required fields are marked *