answersLogoWhite

0

public static int[] reverseArray(int[] array) {

int i = 0, j = array.length - 1;

for (i = 0; i < array.length / 2; i++, j--) {

int temp = array[i];

array[i] = array[j];

array[j] = temp;

}

return array;

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

How do you write a program that outputs a given characters in reverse?

write the javascript code to display the reverse no. of given no. (e.g. 247 reverse of 742)


Write a program to implement the various operations on string such as length of string concatenation reverse of a string copy of a string to another in VB?

what is string


How do you Write a C program to reverse an Integer number.?

Reference:cprogramming-bd.com/c_page2.aspx# reverse number


Write the program in Linux to find the reverse of any string?

i am sam


Write a program to read your name and reverse it using arrays?

abdulrahman


Can you write a program without main in c?

Certainly, you can write a program without main, but you cannot build an executable from it, if that is okay with you.


Write a c program on reverse the diagonal element of matrix?

mano ni anda yarrr


How do we write c program without using swap to interchange values by accessing another variable?

int a,b; a=a+b; b=a-b; a=a-b; that's it simple


Can you write hello world without operating system?

Yes, you can write a &quot;hello world&quot; program without an operating system using bare metal programming. This involves directly interfacing with the hardware of a computer system without an intermediary operating system. The program can be written to access and output text to a display device without the need for an OS.


Can you write a program without specifying the prototype of any function?

You can write a program without specifying its prototype when the function returns an integer.If the prototype is not mentioned the compiler thinks that the return type of the function used is integer.When making program which return integer you can ignore writing the protoype.


How do you Write a program in 'c' language which accepts int numbers from the users print its reverse number x function which return value?

question clarity


How to write a program in python to print the reverse of a number?

In python, type the following into a document. NOTE: Sentences following a # symbol are comments, and are not necessary for the program to run. #!/usr/bin/python #This program takes a input from a user and reverses it. number = input("Type a number: ") #This takes input from a user. a = len(number) #This finds the length of the number reverse = "" #This sets the variable reverse to an empty string. for i in number: a = a-1 #The places in a string start from 0. The last value will be the length minus 1.reverse = reverse + number[a] #Makes the number's last digit the new string's first. print("The reverse of", number, "is", reverse + ".") #prints the resulting string. This program will take any sequence of characters and reverse them. The final value is a string, but if an integer is needed, one needs only to add the line reverse = int(reverse) above the print statement. However, this will stop the program from being able to reverse strings, as it is not possible to convert a string to an integer if it is not a number.