Nepenthe Posted May 30, 2019 Report Share Posted May 30, 2019 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(); } //Ideea e sa imi scoata suma cifrelor pare si a celor impare separat; am facut eu ceva pe aici dar nu prea e treaba. Mersi anticipat! Quote Link to comment Share on other sites More sharing options...
FoxBlood Posted May 30, 2019 Report Share Posted May 30, 2019 Vezi ca dai N /= 10 doar in else Quote Link to comment Share on other sites More sharing options...
Nepenthe Posted May 30, 2019 Author Report Share Posted May 30, 2019 @FoxBlood https://ibb.co/Wx7FDqG degeaba si asa.. ar putea fi vreun Console.Writeline pus pe unde nu trebuie? ca am mai avut problema asta la alt exercitiu Quote Link to comment Share on other sites More sharing options...
FoxBlood Posted May 30, 2019 Report Share Posted May 30, 2019 (edited) @Nepenthe Iti calculeaza foarte bine, problema este ca ai pus Console.Writeline in while, pune-le dupa while. Ultimele numere afisate: 12 si 9 sunt raspunsurile bune Edited May 30, 2019 by FoxBlood 1 Quote Link to comment Share on other sites More sharing options...