- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to print one dimensional array in reverse order?
Firstly, declare and initialize one dimensional array.
int[] arr = { 35, 12, 66, 90, 34, 2, 64 };
Now, use the following to reverse −
Array.Reverse(arr);
The following is the complete code to reverse a one-dimensional array;
Example
using System; class Demo { static void Main() { int[] arr = { 76, 12, 66, 90, 34, 2, 64 }; // Initial Array Console.WriteLine("Original Array= "); foreach (int i in arr) { Console.WriteLine(i); } // Reverse Array Array.Reverse(arr); Console.WriteLine("Reversed Array= "); foreach (int j in arr) { Console.WriteLine(j); } Console.ReadLine(); } }
Output
Original Array= 76 12 66 90 34 2 64 Reversed Array= 64 2 34 90 66 12 76
Advertisements