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

  • Home
  • SEARCH
  • 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 6680267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:27:18+00:00 2026-05-26T04:27:18+00:00

I am putting together a program that takes 20 random numbers, sorts them into

  • 0

I am putting together a program that takes 20 random numbers, sorts them into 4 sections and calculates the min and max values for each section. The issue I’m having is getting the min and max values to reset to default after each run through.

  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.IO;

 namespace 3
{
class Program
{
    static void Main(string[] args)
    {
        string ln;
        string line;
        int value = 0;
        int max = 0;
        int min = 100;

        using (TextReader tr = new StreamReader("values.txt"))
        {
            string currentLine = null;

            do
            {


                for (int i = 1; i < 6; i++)
                {
                    currentLine = tr.ReadLine();

                    if (currentLine == null)
                    {
                        break;
                    }

                    Console.WriteLine(currentLine);
                    value = int.Parse(currentLine);
                    if (value > max)
                   max=value;




                    if (i % 5 == 0)
                    {
                        Console.WriteLine("the Max is " + max);

                        Console.WriteLine("The Min is " + min);

                        Console.WriteLine("-----");
                    }





                }

            } while (currentLine != null);
            Console.ReadLine();
        }
    }
}
}

The error with my code is that I have no way of handling the max values once the highest value ,or min values, have been processed whether it be at the beginning of the file or in the middle.

  • 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-26T04:27:19+00:00Added an answer on May 26, 2026 at 4:27 am

    You can reset max and min “after they are used” – inside the if block, after the printing. Use assignment statements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I putting together a page that will display a set of stored values. I
I am putting together a program that will calculate the area of either a
I'm putting together a small web app that writes to a database (Perl CGI
I am putting together an Java application that needs to display some basic lab
So I've been putting this graphics transformation program together and suddenly some change I
little background: currently putting together a website that is selling products, many of which
I'm putting together a presentation to show some of the productivity gains that I
I'm putting together a simple drop down that contains nested ul's. I want it
I am currently putting together some jQuery that will activate slideDown() when an element
I've been putting together an auditing solution for a program I am developing, where

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.