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 3404010
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:19:49+00:00 2026-05-18T05:19:49+00:00

Question is: Write a program that reads data into an array of type int.

  • 0

Question is:
Write a program that reads data into an array of type int. Valid inputs are from 0 to 10. Your program should determine how many values were inputted. Output a list of distinct entries and a count of how many times that entry occurred.

I have so far:

using System;  
using System.Collections;
namespace ConsoleApplication25
{
class Program
{
   static void Main()
    {
        ArrayList list = new ArrayList();
        string inValue;

        Console.WriteLine("Please enter a value from 0-10");
        Console.WriteLine("To end the program, type 11");
        for (int i = 0; i < 11; i++)
        {
            Console.Write("Enter Value:", i);
            inValue = Console.ReadLine();
            i = int.Parse(inValue);
            list.Add(i);
            list.Remove(11);
            list.Sort();
        }
        int[] c = list.ToArray(typeof(int)) as int[];

        foreach (int value in c)
        {
            Console.WriteLine(value);
        }
        Console.WriteLine("There are {0} values.", list.Count);

        }
    }
}

Where I’m stuck at is displaying a count of each value. I have tried setting up an if with a counter, and setting up cases with breaks and have been unsuccessful. We haven’t started using LINQ yet. Any suggestions or hints would be greatly appreciated.

Thanks,

Jason

  • 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-18T05:19:50+00:00Added an answer on May 18, 2026 at 5:19 am

    Use Dictionary<int, int> to store value and count of how many times it occured. Short example:

    Dictionary<int, int> values = new Dictionary<int, int>();
    ...
    Console.Write("Enter Value:", i);
    inValue = Console.ReadLine();
    i = int.Parse(inValue);
    if(values.ContainsKey(i))
    {
        values[i]++;
    }
    else
    {
        values.Add(i, 1);
    }
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question: Should I write my application to directly access a database Image Repository or
Following on from this question what would be the best way to write a
In a program that I'm trying to write now I take two columns of
Very basic question: how do I write a short literal in C++? I know
Can I write to the end of a 5GB file in Java? This question
This is more of a syntax question I'm trying to write a store procedure
I've a question about KConfig usage. I'm able to write and read settings in
I hope this question is not a RTFM one. I am trying to write
I've got a question about testing methods working on strings. Everytime, I write a
Over in this question, Scott writes that it is possible to get the current

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.