<?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[Variabeln definieren]]></title><description><![CDATA[<p>Hallo alle zusammen<br />
Ich habe mal wieder eine Frage <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="🙂"
    /><br />
Ich habe ein Programm geschrieben dass die anzahl der Münzen vom Benutzer einliest, danauch ausgibt und zusammenrechnet (in Cent) :</p>
<p>#include &quot;std_lib_facilities.h&quot;</p>
<p>int main()<br />
{<br />
cout&lt;&lt;&quot;Geben sie die Anzahl ihrer Münzen wie folgt ein (1Cent 5Cent 10Cent 20Cent 50Cent 1€ 2€ ) \n&quot;;<br />
int cent1;<br />
int cent5;<br />
int cent10;<br />
int cent20;<br />
int cent50;<br />
int euro1;<br />
int euro2;<br />
cin&gt;&gt; cent1 &gt;&gt; cent5 &gt;&gt; cent10 &gt;&gt; cent20 &gt;&gt; cent50 &gt;&gt; euro1 &gt;&gt; euro2;<br />
int cent_main5 = 5;<br />
int cent_main10 = 10;<br />
int cent_main20 = 20;<br />
int cent_main50 = 50;<br />
int euro_main1 = 100;<br />
int euro_main2 = 200;<br />
int cent_right5 = cent5<em>cent_main5;<br />
int cent_right10 = cent10</em>cent_main10;<br />
int cent_right20 = cent20<em>cent_main20;<br />
int cent_right50 = cent50</em>cent_main50;<br />
int euro_right1 = euro1<em>euro_main1;<br />
int euro_right2 = euro2</em>euro_main2;<br />
cout&lt;&lt;&quot;Sie haben: &quot; &lt;&lt; cent1 &lt;&lt;&quot; 1Cent-Stücke \n&quot;;<br />
cout&lt;&lt;&quot;Sie haben: &quot; &lt;&lt; cent5 &lt;&lt;&quot; 5Cent-Stücke \n&quot;;<br />
cout&lt;&lt;&quot;Sie haben: &quot; &lt;&lt; cent10 &lt;&lt;&quot; 10Cent-Stücke \n&quot;;<br />
cout&lt;&lt;&quot;Sie haben: &quot; &lt;&lt; cent20 &lt;&lt;&quot; 20Cent-Stücke \n&quot;;<br />
cout&lt;&lt;&quot;Sie haben: &quot; &lt;&lt; cent50 &lt;&lt;&quot; 50Cent-Stücke \n&quot;;<br />
cout&lt;&lt;&quot;Sie haben: &quot; &lt;&lt; euro1 &lt;&lt;&quot; 1Euro-Stücke \n&quot;;<br />
cout&lt;&lt;&quot;Sie haben: &quot; &lt;&lt; euro2 &lt;&lt;&quot; 2Euro-Stücke \n&quot;;<br />
cout&lt;&lt;&quot;Insgesamt: &quot; &lt;&lt; cent1+cent_right5+cent_right10+cent_right20+cent_right50+ euro_right1+ euro_right2 &lt;&lt;&quot;\n&quot;;<br />
}</p>
<p>Das funktioniert auch soweit, doch finde ich diese Lösung verdammt umständlich.</p>
<p>Ich möchte die int Variabeln (cent_right5 - euro_right2) besser definieren können.</p>
<p>Kann ich nicht auch sowas schrieben:<br />
int cent_right5 = cent5*5; //?</p>
<p>Das funktioniert bei mir nicht</p>
<p>ich habs auch anders probiert:<br />
int cent_right5 = cent5*&quot;5&quot;;<br />
int cent_right5 = cent5*'5';</p>
<p>Ich hab soetwas irgendwo mal gesehen <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>
<p>Liebe Grüße Niklas</p>
<p>P.S: Ich probiere mit dem buch &quot;einführung in die Programmierung mit C++ ) das Programmieren zu lernen<br />
Das ist die Übung nr.11 aus Kapitel 3</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/290444/variabeln-definieren</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 04:01:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/290444.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 26 Jul 2011 17:41:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Variabeln definieren on Tue, 26 Jul 2011 17:41:00 GMT]]></title><description><![CDATA[<p>Hallo alle zusammen<br />
Ich habe mal wieder eine Frage <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="🙂"
    /><br />
Ich habe ein Programm geschrieben dass die anzahl der Münzen vom Benutzer einliest, danauch ausgibt und zusammenrechnet (in Cent) :</p>
<p>#include &quot;std_lib_facilities.h&quot;</p>
<p>int main()<br />
{<br />
cout&lt;&lt;&quot;Geben sie die Anzahl ihrer Münzen wie folgt ein (1Cent 5Cent 10Cent 20Cent 50Cent 1€ 2€ ) \n&quot;;<br />
int cent1;<br />
int cent5;<br />
int cent10;<br />
int cent20;<br />
int cent50;<br />
int euro1;<br />
int euro2;<br />
cin&gt;&gt; cent1 &gt;&gt; cent5 &gt;&gt; cent10 &gt;&gt; cent20 &gt;&gt; cent50 &gt;&gt; euro1 &gt;&gt; euro2;<br />
int cent_main5 = 5;<br />
int cent_main10 = 10;<br />
int cent_main20 = 20;<br />
int cent_main50 = 50;<br />
int euro_main1 = 100;<br />
int euro_main2 = 200;<br />
int cent_right5 = cent5<em>cent_main5;<br />
int cent_right10 = cent10</em>cent_main10;<br />
int cent_right20 = cent20<em>cent_main20;<br />
int cent_right50 = cent50</em>cent_main50;<br />
int euro_right1 = euro1<em>euro_main1;<br />
int euro_right2 = euro2</em>euro_main2;<br />
cout&lt;&lt;&quot;Sie haben: &quot; &lt;&lt; cent1 &lt;&lt;&quot; 1Cent-Stücke \n&quot;;<br />
cout&lt;&lt;&quot;Sie haben: &quot; &lt;&lt; cent5 &lt;&lt;&quot; 5Cent-Stücke \n&quot;;<br />
cout&lt;&lt;&quot;Sie haben: &quot; &lt;&lt; cent10 &lt;&lt;&quot; 10Cent-Stücke \n&quot;;<br />
cout&lt;&lt;&quot;Sie haben: &quot; &lt;&lt; cent20 &lt;&lt;&quot; 20Cent-Stücke \n&quot;;<br />
cout&lt;&lt;&quot;Sie haben: &quot; &lt;&lt; cent50 &lt;&lt;&quot; 50Cent-Stücke \n&quot;;<br />
cout&lt;&lt;&quot;Sie haben: &quot; &lt;&lt; euro1 &lt;&lt;&quot; 1Euro-Stücke \n&quot;;<br />
cout&lt;&lt;&quot;Sie haben: &quot; &lt;&lt; euro2 &lt;&lt;&quot; 2Euro-Stücke \n&quot;;<br />
cout&lt;&lt;&quot;Insgesamt: &quot; &lt;&lt; cent1+cent_right5+cent_right10+cent_right20+cent_right50+ euro_right1+ euro_right2 &lt;&lt;&quot;\n&quot;;<br />
}</p>
<p>Das funktioniert auch soweit, doch finde ich diese Lösung verdammt umständlich.</p>
<p>Ich möchte die int Variabeln (cent_right5 - euro_right2) besser definieren können.</p>
<p>Kann ich nicht auch sowas schrieben:<br />
int cent_right5 = cent5*5; //?</p>
<p>Das funktioniert bei mir nicht</p>
<p>ich habs auch anders probiert:<br />
int cent_right5 = cent5*&quot;5&quot;;<br />
int cent_right5 = cent5*'5';</p>
<p>Ich hab soetwas irgendwo mal gesehen <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>
<p>Liebe Grüße Niklas</p>
<p>P.S: Ich probiere mit dem buch &quot;einführung in die Programmierung mit C++ ) das Programmieren zu lernen<br />
Das ist die Übung nr.11 aus Kapitel 3</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2098101</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2098101</guid><dc:creator><![CDATA[Raider95]]></dc:creator><pubDate>Tue, 26 Jul 2011 17:41:00 GMT</pubDate></item><item><title><![CDATA[Reply to Variabeln definieren on Tue, 26 Jul 2011 17:44:44 GMT]]></title><description><![CDATA[<p>Raider95 schrieb:</p>
<blockquote>
<p>int cent_right5 = cent5*5; //?</p>
</blockquote>
<p>Das sollte eigentlich so funktionieren. Wenn nicht, wie lautet denn die Meldung des Compilers?</p>
<p>Btw, ich hätte ja alle Münzen in einem vector&lt;&gt; untergebracht und mir den ganzen Haufen Variablen erspart.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2098102</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2098102</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 26 Jul 2011 17:44:44 GMT</pubDate></item><item><title><![CDATA[Reply to Variabeln definieren on Tue, 26 Jul 2011 18:01:41 GMT]]></title><description><![CDATA[<p>Vielleicht etwas mehr als du schon kennst, aber das lernst du bald:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;

int main()
{
  const int muenzwerte[8] = {1, 2, 5, 10, 20, 50, 100, 200};
  const string muenznamen[8] = {&quot;1 Cent&quot;, &quot;2 Cent&quot;, &quot;5 Cent&quot;, &quot;10 Cent&quot;, &quot;20 Cent&quot;, &quot;50 Cent&quot;, &quot;1 Euro&quot;, &quot;2 Euro&quot;};
  int muenzanzahl[8];

  cout &lt;&lt; &quot;Geben sie die Anzahl ihrer Münzen wie folgt ein!\n&quot;;
  for (unsigned i = 0; i&lt;8; ++i)
    {
      cout &lt;&lt; &quot;Wieviele &quot; &lt;&lt; muenznamen[i] &lt;&lt; &quot; Stücke? &quot;;
      cin &gt;&gt; muenzanzahl[i];
     }

  int gesamtwert =0;
  for (unsigned i = 0; i&lt;8; ++i)
    {
      cout &lt;&lt; &quot;Sie haben &quot; &lt;&lt; muenzanzahl[i] &lt;&lt; &quot; &quot; &lt;&lt; muenznamen[i] &lt;&lt; &quot; Stücke.\n&quot;;
      gesamtwert += muenzanzahl[i] * muenzwerte[i];
    }

  cout &lt;&lt; &quot;Insgesamt &quot; &lt;&lt; gesamtwert &lt;&lt; &quot; Cent.\n&quot;;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2098109</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2098109</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 26 Jul 2011 18:01:41 GMT</pubDate></item><item><title><![CDATA[Reply to Variabeln definieren on Tue, 26 Jul 2011 18:12:41 GMT]]></title><description><![CDATA[<p>Sry für die sinnlose frage<br />
Jetzt funktioniert es so wie CStoll gesagt hat <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>
<p>Trotzdem danke für die schnelle Hilfe</p>
<p>Noch eine kleine Frage :<br />
Wie poste ich meinen Code so wie SeppJ ?</p>
<p>Liebe Grüße Niklas</p>
<p>P.S: @ SeppJ Nach Kapitel 4 sollte ich es verstehen können <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2098115</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2098115</guid><dc:creator><![CDATA[Raider95]]></dc:creator><pubDate>Tue, 26 Jul 2011 18:12:41 GMT</pubDate></item><item><title><![CDATA[Reply to Variabeln definieren on Tue, 26 Jul 2011 18:16:10 GMT]]></title><description><![CDATA[<p>Raider95 schrieb:</p>
<blockquote>
<p>Noch eine kleine Frage :<br />
Wie poste ich meinen Code so wie SeppJ ?</p>
</blockquote>
<p>sfds</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2098117</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2098117</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 26 Jul 2011 18:16:10 GMT</pubDate></item><item><title><![CDATA[Reply to Variabeln definieren on Tue, 26 Jul 2011 18:17:25 GMT]]></title><description><![CDATA[<p>Raider95 schrieb:</p>
<blockquote>
<p>Noch eine kleine Frage :<br />
Wie poste ich meinen Code so wie SeppJ ?</p>
</blockquote>
<p>Du schreibst vor dem Code [cpp] und nach dem Code [/cpp]</p>
<p>Links unter dem Editfenster (unter den Smileys) macht der Button C/C++ das auch. Da sind auch allerlei andere interessante Tags die man benutzen kann um die Beiträge zu verschönern.</p>
<p>edit: Zu langsam.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2098118</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2098118</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 26 Jul 2011 18:17:25 GMT</pubDate></item><item><title><![CDATA[Reply to Variabeln definieren on Tue, 26 Jul 2011 18:22:16 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">Danke!
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2098123</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2098123</guid><dc:creator><![CDATA[Raider95]]></dc:creator><pubDate>Tue, 26 Jul 2011 18:22:16 GMT</pubDate></item></channel></rss>