Write C# program to find reverse of an array


Introduction

I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability.


techstudy.org

Kindle Paperwhite High Resolution Display Tablet | Rs. 9999

  1. using System;
  2. class Program
  3. {
  4. static void Main()
  5. {
  6.  
  7.  
  8. int[] array = new int[100];
  9. int size, i;
  10.  
  11.  
  12. //Reads size of the array
  13. Console.WriteLine("Enter size of the array: ");
  14. size = Convert.ToInt32(Console.ReadLine());
  15.  
  16. //Reads elements in array
  17. Console.WriteLine("Enter elements in array: ");
  18. for (i = 0; i < size; i++)
  19. {
  20. array[i] = Convert.ToInt32(Console.ReadLine());
  21. }
  22.  
  23. //Print array in reversed order
  24. Console.WriteLine("\nArray in reverse order: ");
  25. for (i = size - 1; i >= 0; i--)
  26. {
  27. Console.Write("\t"+ array[i]);
  28. }
  29.  
  30. Console.ReadLine();
  31. }
  32.  
  33. }

Result

C# language techstudy

     





Related Topics


Responses




Popular Posts

Facebook

Founded in 2016, Tech Study passionately delivers stylish and dynamic innovative information to programmer and technology lovers. http://www.techstudy.org/.