-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
38 lines (29 loc) · 953 Bytes
/
Program.cs
File metadata and controls
38 lines (29 loc) · 953 Bytes
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
33
34
35
36
37
38
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DecimalToBinaryWithModulo
{
class Program
{ /// <summary>
/// Doxygen Doku bzw. XML Format Doku
/// Die Parameter aus der Main habe keine Bedeutung!
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
int dezimalZahl;
Console.WriteLine("Geben Sie eine Dezimalzahl ein:");
dezimalZahl = Convert.ToInt32(Console.ReadLine());
string ergebnisBinary = string.Empty;
for (int i = 0; dezimalZahl > 0; i++)
{
ergebnisBinary = dezimalZahl % 2 + ergebnisBinary;
dezimalZahl /= 2;
}
Console.WriteLine($"Die Binäre Zahl lautet: {ergebnisBinary}");
Console.ReadKey();
}
}
}