@SebiDragu/

Help - math(C#)

C#

I need help with a math problem in C#.

fork
loading
Files
  • main.cs
  • main.exe
main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;

class MainClass {
  public static void Main (string[] args) {
    Console.WriteLine ("Hello World");
  }
  public static void math4()
        {
            int sum = 0;
            int sum1 = 0;
            int C = 0;
            Console.Write("Enter a number: ");
            int N = Int32.Parse(Console.ReadLine());
            
            while(N > 0)
            {
                C = N % 10;
                if (C % 2 == 0)
                {
                    sum += C;
                    Console.WriteLine("Sum even of {0} is {1}.", N, sum);
                }
                else
                {
                    sum1 += C;
                    N /= 10;
                    Console.WriteLine("Suma odd of {0} is {1}.", N, sum1);
                }
            }
            Console.ReadLine();
        }
}