5
Answers

Need Help With Program

Ya Boi

Ya Boi

7y
183
1
I need a program whose Main() method declares three integers named firstInt, middleInt, and lastInt.
 

Assign the following values to the integers:

  • 23 to firstInt
  • 45 to middleInt
  • 67 to lastInt

Then display the values and pass them to a method named Reverse that accepts them as reference variables, places the first value in the lastIntvariable, and places the last value in the firstInt variable.

In the Main() method, display the three variables again, demonstrating that their positions have been reversed. I have this:

using static System.Console;
class Reverse3
{
static void Main()
{
 
 
and I wrote the other method:
 
public static void Reverse(ref int a, ref int b, ref int c)
{
}
}
 
I am completely lost on what I need to put in them. 
Answers (5)
0
Ashwani Bakshi

Ashwani Bakshi

NA 286 3.7k 7y
using System;
namespace error2
{
class Program
{
public static void qube(ref int first, ref int middle, ref int last)
{
int temp = 0;
temp = first;
first = last;
last = temp;
}
static void Main(string[] args)
{
int first=23;int middle = 45;int last = 67;
Console.Write("\ncurrent value of first middle last is {0} {1} {2}\t",first,middle,last);
Program.qube(ref first,ref middle,ref last);
Console.WriteLine("\nNow the first middle last is {0} {1} {2}\t", first,middle,last);
Console.ReadLine();
}
}
}
0
Ya Boi

Ya Boi

NA 27 1.2k 7y
I got you. Let me look through the textbook one more time and try some things out.
0
Chetan Ranpariya

Chetan Ranpariya

NA 1.6k 234 7y
But you don't even show an attempt to solve the issue. At least try to write code which even though it is breaking and try to resolve errors. Ready made answers from here will solve the issue but won't help you learning. For this specific problem the logic is you need to swap the values of firstInt and lastInt. Try to implement this logic and come back here if you are facing issue in the code of that.
0
Ya Boi

Ya Boi

NA 27 1.2k 7y
No. I more need help understanding how to do them. I am having trouble understanding the concepts currently.
0
Chetan Ranpariya

Chetan Ranpariya

NA 1.6k 234 7y
Are you getting your homework done by posting questions here?