I am new to C# and I am learning to reverse integers (numbers). I have to use forloop and an array to complete the code but i really have no idea how to use those.
For example. If the input is: 1 2 3 4 5 6
Results should be : 6 5 4 3 2 1
Can someone please help me. Thank you :)
Edit: I am really sorry guys, I forgot to add the code. Here it is. Thanks again
static void Main(string[] args)
{
Console.WriteLine("Enter 6 Numbers");
int numb = int.Parse(Console.ReadLine());
int reverse = 0;
while (numb > 0)
{
int rem = numb % 10;
reverse = (reverse * 10) + rem;
numb = numb / 10;
}
Console.WriteLine("The reverse is = {0}", reverse);
Console.ReadLine();
}
Edit
Here a string is taken as input and need to be reversed. Just due to the input is taken as numbers only so this is confusing little bit.
int[] Reverse(int[] source)or maybevoid ReverseInPlace(int[] array).