this is my code using System; class Reverse3 { static void Main() { int firstInt = 23; int middleInt = 45; int lastInt = 67; Console.WriteLine("Before reversing: firstInt: " + firstInt + ", middleInt: " + middleInt + ", lastInt: " + lastInt); Reverse(ref firstInt, ref middleInt, ref lastInt); Console.WriteLine("After reversing: firstInt: " + firstInt + ", middleInt: " + middleInt + ", lastInt: " + lastInt); Console.WriteLine("Values in order: " + firstInt + ", " + middleInt + ", " + lastInt); Console.WriteLine("Values in reverse order: " + lastInt + ", " + middleInt + ", " + firstInt); } public static void Reverse(ref int a, ref int b, ref int c) { int temp = a; a = c; c = temp; } } i have my task Function Reverse reverses the position of three integers, and this one works but the task Values printed in order and in reverse order only half works I get them in reverse order Values in reverse order: 23, 45, 67 but not in order of 67, 45, 23 I need the Values printed in order and in reverse order
this is my code
using System;
class Reverse3
{
static void Main()
{
int firstInt = 23;
int middleInt = 45;
int lastInt = 67;
Console.WriteLine("Before reversing: firstInt: " + firstInt + ", middleInt: " + middleInt + ", lastInt: " + lastInt);
Reverse(ref firstInt, ref middleInt, ref lastInt);
Console.WriteLine("After reversing: firstInt: " + firstInt + ", middleInt: " + middleInt + ", lastInt: " + lastInt);
Console.WriteLine("Values in order: " + firstInt + ", " + middleInt + ", " + lastInt);
Console.WriteLine("Values in reverse order: " + lastInt + ", " + middleInt + ", " + firstInt);
}
public static void Reverse(ref int a, ref int b, ref int c)
{
int temp = a;
a = c;
c = temp;
}
}
i have my task Function Reverse reverses the position of three integers, and this one works but the task
Values printed in order and in reverse order only half works I get them in reverse order Values in reverse order: 23, 45, 67 but not in order of 67, 45, 23 I need the Values printed in order and in reverse order
Step by step
Solved in 2 steps with 1 images