© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
35 replies
js

function not running

int count = 1;
Console.WriteLine("Oyster Eating Competition\nHow many competitors are there?");
int numCompetitors = int.Parse(Console.ReadLine());
string[] names = new string[numCompetitors];
int[] oystersEaten = new int[numCompetitors];

for (int i = 0; i < numCompetitors; i++)
{
    Console.WriteLine($"What is competitor number {count}'s name?");
    names[i] = Console.ReadLine();
    Console.WriteLine($"How many oysters did {names[i]} eat?");
    oystersEaten[i] = int.Parse(Console.ReadLine());
    count = count + 1;
}
static void bubbleSort(int[] oystersEaten)
{
    int temp;

    for (int i = 0;i < oystersEaten.Length - 1; i++)
    {
        for(int j = 0; j < oystersEaten.Length - (1 + i); j++)
        {
            if (oystersEaten[j] > oystersEaten[j + 1])
            {
                temp = oystersEaten[j + 1];
                oystersEaten[j +1] = oystersEaten[j];
                oystersEaten[j] = temp;
            }
        }
    }
}
p.bubbleSort();
Console.WriteLine(string.Join(", ", oystersEaten));
int count = 1;
Console.WriteLine("Oyster Eating Competition\nHow many competitors are there?");
int numCompetitors = int.Parse(Console.ReadLine());
string[] names = new string[numCompetitors];
int[] oystersEaten = new int[numCompetitors];

for (int i = 0; i < numCompetitors; i++)
{
    Console.WriteLine($"What is competitor number {count}'s name?");
    names[i] = Console.ReadLine();
    Console.WriteLine($"How many oysters did {names[i]} eat?");
    oystersEaten[i] = int.Parse(Console.ReadLine());
    count = count + 1;
}
static void bubbleSort(int[] oystersEaten)
{
    int temp;

    for (int i = 0;i < oystersEaten.Length - 1; i++)
    {
        for(int j = 0; j < oystersEaten.Length - (1 + i); j++)
        {
            if (oystersEaten[j] > oystersEaten[j + 1])
            {
                temp = oystersEaten[j + 1];
                oystersEaten[j +1] = oystersEaten[j];
                oystersEaten[j] = temp;
            }
        }
    }
}
p.bubbleSort();
Console.WriteLine(string.Join(", ", oystersEaten));

it runs fine up until p.bubbleSort i think, im not sure how to call my function properly im just trying to use the sort to sort the array
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

fail to achieve bounce using return, update not running function
C#CC# / help
13mo ago
✅ Benchmarks not running
C#CC# / help
2y ago
Main not running?
C#CC# / help
2y ago
Targets not running
C#CC# / help
2y ago