© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
6 replies
𝙔⁴⁴

❔ hw help

using System;
                    
public class Program
{
    public static int CountEven (int num)
    {
        int digit;
        int evencount = 0;
        while (num != 0)
        {
            digit = num % 10;
            if (num % 2 == 0)
            {
                evencount++;
            }
            num = num/10;
        }
        return evencount;
    }
    public static void Main()
    {
        int n;
        Console.WriteLine("Write how many numbers are there?");
        n = int.Parse(Console.ReadLine());
        for ( int i = 1 ; i <= n ; i++)
        {
            int c;int y = 0;int Max = 0;
            c= int.Parse(Console.ReadLine());
            Console.WriteLine( "This number has this much even numbers: " + CountEven(c));
            if (CountEven(c) > y)
            {
                y = CountEven(c);
                Max = Math.Max(y,Max);
                Console.WriteLine("This number has the most even numbers:" + Max);
            }
        }
    }
}
using System;
                    
public class Program
{
    public static int CountEven (int num)
    {
        int digit;
        int evencount = 0;
        while (num != 0)
        {
            digit = num % 10;
            if (num % 2 == 0)
            {
                evencount++;
            }
            num = num/10;
        }
        return evencount;
    }
    public static void Main()
    {
        int n;
        Console.WriteLine("Write how many numbers are there?");
        n = int.Parse(Console.ReadLine());
        for ( int i = 1 ; i <= n ; i++)
        {
            int c;int y = 0;int Max = 0;
            c= int.Parse(Console.ReadLine());
            Console.WriteLine( "This number has this much even numbers: " + CountEven(c));
            if (CountEven(c) > y)
            {
                y = CountEven(c);
                Max = Math.Max(y,Max);
                Console.WriteLine("This number has the most even numbers:" + Max);
            }
        }
    }
}

now i want this code to show me the number that has the most even numbers but it keeps showing me how much even numbers the numbers has instead even tho i have the max command
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

c# hw help
C#CC# / help
5mo ago
❔ help in hw
C#CC# / help
3y ago
❔ c# hw help
C#CC# / help
4y ago
✅ some help in hw
C#CC# / help
3y ago