Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4016430
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:44:20+00:00 2026-05-20T09:44:20+00:00

I have a method that has 2 output parameters. The method should take an

  • 0

I have a method that has 2 output parameters. The method should take an array and return both the sum and the average of the values in the array. There is another method that creates an array from user input. The array needs to be initialized from the main method. I am really stumped with this one. I hope you guys can help. I have included my code below.

// Create a console-based application whose Main() method declares an array of eight integers.
//
// Call a method to interactivelyfill the array with any number of values up to eight.
//
// Call a second method that accepts out parameters for the arithmetic average and the sum of the values in the array.
//
// Display the array values, the number of entered elements, and their average and sum in the Main() method.


using System;

namespace ArrayManagment
{
    class Program
    {
        static void arrayMath(out int sum, out int avg)
        {
           sum = myArray.Sum();
           avg = myArray.Average();
        }
        static void displayArray(int[] myArray)
        {
            Console.Write("Your numbers are: ");
            for (int i = 0; i < 8; i++)
                Console.Write(myArray[i] + " ");
            Console.WriteLine();

        }

        static int[] fillArray()
        {
            int[] myArray;
            myArray = new int[8];
            int count = 0;
            do
            {
                Console.Write("Please enter a number to add to the array or \"x\" to stop: ");
                string consoleInput = Console.ReadLine();
                if (consoleInput == "x")
                {
                    return myArray;
                }
                else
                {
                    myArray[count] = Convert.ToInt32(consoleInput);
                    ++count;
                }

            } while (count < 8);

            return myArray;

        }

        static void Main(string[] args)
        {
            int[] myArray;
            myArray = new int[8];
            myArray = fillArray();
            int sum, avg;
            arrayMath(out sum, out avg);

            displayArray(myArray);


        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:44:21+00:00Added an answer on May 20, 2026 at 9:44 am

    Just put it as a parameter before the output parameters:

    static void arrayMath(int[] myArray, out int sum, out int avg)
    

    (There is no need for it to be before the output parameters, but it just makes sense.)

    Then send in the array to the method in the Main method:

    arrayMath(myArray, out sum, out avg);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

You have a method on a class that has 2 parameters, one of which
I have a method that can return either a single object or a collection
I have a method that takes an IQueryable. Is there a LINQ query that
I have a method that needs to accept an array of country names, and
My current method: if there's a function that I know has an bug, I
I have a recursive method that reversed a string (HW assignment, has to be
I have a vector class that has it's Equals(object obj) method overridden so that
I have a base class for many tests that has some helper methods they
I have class method that returns a list of employees that I can iterate
I have a method that where I want to redirect the user back to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.