Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
added a program in R to reverse an array (#4766)
Browse files Browse the repository at this point in the history
Co-authored-by: Anandha Krishnan S <[email protected]>
Co-authored-by: Harsh Raj <[email protected]>
  • Loading branch information
3 people authored Dec 1, 2023
1 parent 2f3ef81 commit d4ce70d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions program/program/reverse-an-array/reverse_an_array.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Function to reverse an array
reverse_array <- function(arr) {
return(rev(arr))
}

# Example usage
input_array <- c(1, 2, 3, 4, 5)
output_array <- reverse_array(input_array)

# Print the result
cat("Input array: ", input_array, "\n")
cat("Reversed array: ", output_array, "\n")

0 comments on commit d4ce70d

Please sign in to comment.