<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Dezimalzahl als Binärzahl darstellen]]></title><description><![CDATA[<p>Ich habe versucht dafür ein Programm zu schreiben... das ist wohl in die Hose gegangen, ich erhalte als Binärzahl freundlicherweise anstatt dieser eine Hexadezimalzahl...</p>
<p>Wißt ihr einen Rat?</p>
<pre><code>#include &lt;iostream&gt;
using namespace std;

int Anzahl_Ziffern_berechnen (int _Dezimalzahl);

int main()
{
	int Hauptauswahl;

	while (true)
	{
	    cout &lt;&lt; &quot;[1] Dezimalzahl als Binaerzahl ausdruecken&quot; &lt;&lt; endl;
	    cout &lt;&lt; &quot;Eingabe: &quot;; cin &gt;&gt; Hauptauswahl; cout &lt;&lt; endl;

	    switch (Hauptauswahl)
	    {
		    case(1):
		    {
			    cout &lt;&lt; &quot;Dezimalzahl eingeben: &quot;; int Dezimalzahl; cin &gt;&gt; Dezimalzahl;

			    int Anzahl_Ziffern = Anzahl_Ziffern_berechnen(Dezimalzahl);
			    int Binaerzahl[Anzahl_Ziffern];

			    for(int i = 0; i &lt; Anzahl_Ziffern - 1; i++)
			    {
			    	Binaerzahl[i] = Dezimalzahl % 2;
			    	Dezimalzahl = Dezimalzahl / 2;
				}

				cout &lt;&lt; &quot;Binaerzahl: &quot; &lt;&lt; Binaerzahl&lt;&lt; endl;

		    } break;

		    default: cout &lt;&lt; &quot;Falsche Eingabe!&quot; &lt;&lt; endl;
	    }

	    cout &lt;&lt; endl;
    }
}

int Anzahl_Ziffern_berechnen (int _Dezimalzahl)
{
    int anzahl_ziffern = 0;	

	while (_Dezimalzahl != 0)
	{
		_Dezimalzahl = _Dezimalzahl / 2;
		anzahl_ziffern++;
	}
    return anzahl_ziffern;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/333050/dezimalzahl-als-binärzahl-darstellen</link><generator>RSS for Node</generator><lastBuildDate>Mon, 27 Apr 2026 07:56:22 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/333050.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 08 Jun 2015 17:44:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dezimalzahl als Binärzahl darstellen on Mon, 08 Jun 2015 17:48:34 GMT]]></title><description><![CDATA[<p>Ich habe versucht dafür ein Programm zu schreiben... das ist wohl in die Hose gegangen, ich erhalte als Binärzahl freundlicherweise anstatt dieser eine Hexadezimalzahl...</p>
<p>Wißt ihr einen Rat?</p>
<pre><code>#include &lt;iostream&gt;
using namespace std;

int Anzahl_Ziffern_berechnen (int _Dezimalzahl);

int main()
{
	int Hauptauswahl;

	while (true)
	{
	    cout &lt;&lt; &quot;[1] Dezimalzahl als Binaerzahl ausdruecken&quot; &lt;&lt; endl;
	    cout &lt;&lt; &quot;Eingabe: &quot;; cin &gt;&gt; Hauptauswahl; cout &lt;&lt; endl;

	    switch (Hauptauswahl)
	    {
		    case(1):
		    {
			    cout &lt;&lt; &quot;Dezimalzahl eingeben: &quot;; int Dezimalzahl; cin &gt;&gt; Dezimalzahl;

			    int Anzahl_Ziffern = Anzahl_Ziffern_berechnen(Dezimalzahl);
			    int Binaerzahl[Anzahl_Ziffern];

			    for(int i = 0; i &lt; Anzahl_Ziffern - 1; i++)
			    {
			    	Binaerzahl[i] = Dezimalzahl % 2;
			    	Dezimalzahl = Dezimalzahl / 2;
				}

				cout &lt;&lt; &quot;Binaerzahl: &quot; &lt;&lt; Binaerzahl&lt;&lt; endl;

		    } break;

		    default: cout &lt;&lt; &quot;Falsche Eingabe!&quot; &lt;&lt; endl;
	    }

	    cout &lt;&lt; endl;
    }
}

int Anzahl_Ziffern_berechnen (int _Dezimalzahl)
{
    int anzahl_ziffern = 0;	

	while (_Dezimalzahl != 0)
	{
		_Dezimalzahl = _Dezimalzahl / 2;
		anzahl_ziffern++;
	}
    return anzahl_ziffern;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2456134</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2456134</guid><dc:creator><![CDATA[Vengeancos]]></dc:creator><pubDate>Mon, 08 Jun 2015 17:48:34 GMT</pubDate></item><item><title><![CDATA[Reply to Dezimalzahl als Binärzahl darstellen on Mon, 08 Jun 2015 18:18:46 GMT]]></title><description><![CDATA[<p>Das liegt daran, dass du ein int array ausgeben willst.<br />
std::cout kann aber keine int arrays ausgeben, wohl aber pointer auf int. Das Array zerfällt also zu einem Pointer auf int, der wird dann ausgegeben. Und Pointer werden ausgegeben, indem die gespeicherte Adresse ausgegeben wird.<br />
Du musst also jede Ziffer in dem Array einzeln ausgeben oder ein char array verwenden, was dann die Zeichen speichert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2456139</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2456139</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Mon, 08 Jun 2015 18:18:46 GMT</pubDate></item><item><title><![CDATA[Reply to Dezimalzahl als Binärzahl darstellen on Mon, 08 Jun 2015 18:34:56 GMT]]></title><description><![CDATA[<p>Stimmt, ist mir auch aufgefallen. Ich hab's dementsprechend geändert. Leider verweigert mir das Programm nun schlicht die Ausgabe des Binärzahl. Alles andere jedoch wird ausgegeben.</p>
<pre><code>#include &lt;iostream&gt;
using namespace std;

int Anzahl_Ziffern_berechnen (int _Dezimalzahl);

int main()
{
	int Hauptauswahl;

	while (true)
	{
	    cout &lt;&lt; &quot;[1] Dezimalzahl als Binaerzahl ausdruecken&quot; &lt;&lt; endl;
	    cout &lt;&lt; &quot;Eingabe: &quot;; cin &gt;&gt; Hauptauswahl; cout &lt;&lt; endl;

	    switch (Hauptauswahl)
	    {
		    case(1):
		    {
			    cout &lt;&lt; &quot;Dezimalzahl eingeben: &quot;; int Dezimalzahl; cin &gt;&gt; Dezimalzahl;

			    int Anzahl_Ziffern = Anzahl_Ziffern_berechnen(Dezimalzahl);
			    int Binaerzahl[Anzahl_Ziffern];

			    for(int i = 0; i &lt; Anzahl_Ziffern - 1; i++)
			    {
			    	Binaerzahl[i] = Dezimalzahl % 2;
			    	Dezimalzahl = Dezimalzahl / 2;
				}

				cout &lt;&lt; &quot;Binaerzahl: &quot;;
				for(int i = 0; i &lt; Anzahl_Ziffern - 1; i++)
				{
					cout &lt;&lt; Binaerzahl[i];
				}

				cout &lt;&lt; endl;

		    } break;

		    default: cout &lt;&lt; &quot;Falsche Eingabe!&quot; &lt;&lt; endl;
	    }

	    cout &lt;&lt; endl;
    }
}

int Anzahl_Ziffern_berechnen (int _Dezimalzahl)
{
    int anzahl_ziffern = 0;	

	while (_Dezimalzahl != 0)
	{
		_Dezimalzahl = _Dezimalzahl / 2;
		anzahl_ziffern++;
		return anzahl_ziffern;
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2456146</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2456146</guid><dc:creator><![CDATA[Vengeancos]]></dc:creator><pubDate>Mon, 08 Jun 2015 18:34:56 GMT</pubDate></item><item><title><![CDATA[Reply to Dezimalzahl als Binärzahl darstellen on Mon, 08 Jun 2015 18:42:33 GMT]]></title><description><![CDATA[<p>Kuckst du hier:<br />
<a href="https://www.c-plusplus.net/forum/330503-10?highlight=bin%E4r">https://www.c-plusplus.net/forum/330503-10?highlight=bin�r</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2456147</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2456147</guid><dc:creator><![CDATA[EOP]]></dc:creator><pubDate>Mon, 08 Jun 2015 18:42:33 GMT</pubDate></item><item><title><![CDATA[Reply to Dezimalzahl als Binärzahl darstellen on Mon, 08 Jun 2015 19:53:29 GMT]]></title><description><![CDATA[<p>Oh, gabs ja schon. Vielen Dank für den Hinweis <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2456155</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2456155</guid><dc:creator><![CDATA[Vengeancos]]></dc:creator><pubDate>Mon, 08 Jun 2015 19:53:29 GMT</pubDate></item></channel></rss>