<?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[Warum funktioniert dieses Programm net?^^]]></title><description><![CDATA[<p>Hallo,<br />
Ich habe eine Frage und zwar: Ich habe einen kleinen &quot;Rechner&quot; programmiert (mein erstes Programm), allerdings funktioniert dieser leider nicht wie geplant, es kommt zwar keine Fehlermeldung oder so, aber immer wenn ich das Programm ausführe und 2 Zahlen addiere oder so kommt immer das Gleiche raus, eine total unlogische Zahl. Ich gebe euch mal den Quellcode, pls help me^^</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;cmath&gt;
using namespace std;
int main()
{
  double Zahl1; // Erste Zahl
  double Zahl2; // Zweite Zahl
  int Frage; // Siehe 3. cout
  double Ergebnis; // Ergebnis aus Zahl1 &amp; Zahl 2

  cout &lt;&lt; &quot;Geben Sie die erste Zahl ein&quot; &lt;&lt; endl;
  cin &gt;&gt; Zahl1;
  cout &lt;&lt; &quot;Geben Sie die zweite Zahl ein&quot; &lt;&lt; endl;
  cin &gt;&gt; Zahl2;
  cout &lt;&lt; &quot;Wollen Sie addieren (1) , subtrahieren (2) , multiplizieren (3) oder dividieren(4) ?&quot; &lt;&lt; endl;
  cin &gt;&gt; Frage;

  if (Frage == 1 )
  {
 Ergebnis == Zahl1 + Zahl2;
  cout &lt;&lt; Ergebnis &lt;&lt; endl;
  }

  if (Frage ==  2 )
  {
    Ergebnis == Zahl1 - Zahl2;
    cout &lt;&lt; Ergebnis &lt;&lt; endl;
  }

  if (Frage == 3 )
  {
    Ergebnis == Zahl1 * Zahl2;
    cout &lt;&lt; Ergebnis &lt;&lt; endl;
  }

  if (Frage == 4 )
  {
    Ergebnis == Zahl1 / Zahl2;
    cout &lt;&lt; Ergebnis &lt;&lt; endl;
  }

return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/162555/warum-funktioniert-dieses-programm-net</link><generator>RSS for Node</generator><lastBuildDate>Sat, 12 Sep 2026 16:46:05 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/162555.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 19 Oct 2006 17:42:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Warum funktioniert dieses Programm net?^^ on Thu, 19 Oct 2006 17:42:26 GMT]]></title><description><![CDATA[<p>Hallo,<br />
Ich habe eine Frage und zwar: Ich habe einen kleinen &quot;Rechner&quot; programmiert (mein erstes Programm), allerdings funktioniert dieser leider nicht wie geplant, es kommt zwar keine Fehlermeldung oder so, aber immer wenn ich das Programm ausführe und 2 Zahlen addiere oder so kommt immer das Gleiche raus, eine total unlogische Zahl. Ich gebe euch mal den Quellcode, pls help me^^</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;cmath&gt;
using namespace std;
int main()
{
  double Zahl1; // Erste Zahl
  double Zahl2; // Zweite Zahl
  int Frage; // Siehe 3. cout
  double Ergebnis; // Ergebnis aus Zahl1 &amp; Zahl 2

  cout &lt;&lt; &quot;Geben Sie die erste Zahl ein&quot; &lt;&lt; endl;
  cin &gt;&gt; Zahl1;
  cout &lt;&lt; &quot;Geben Sie die zweite Zahl ein&quot; &lt;&lt; endl;
  cin &gt;&gt; Zahl2;
  cout &lt;&lt; &quot;Wollen Sie addieren (1) , subtrahieren (2) , multiplizieren (3) oder dividieren(4) ?&quot; &lt;&lt; endl;
  cin &gt;&gt; Frage;

  if (Frage == 1 )
  {
 Ergebnis == Zahl1 + Zahl2;
  cout &lt;&lt; Ergebnis &lt;&lt; endl;
  }

  if (Frage ==  2 )
  {
    Ergebnis == Zahl1 - Zahl2;
    cout &lt;&lt; Ergebnis &lt;&lt; endl;
  }

  if (Frage == 3 )
  {
    Ergebnis == Zahl1 * Zahl2;
    cout &lt;&lt; Ergebnis &lt;&lt; endl;
  }

  if (Frage == 4 )
  {
    Ergebnis == Zahl1 / Zahl2;
    cout &lt;&lt; Ergebnis &lt;&lt; endl;
  }

return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1157864</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157864</guid><dc:creator><![CDATA[AnfängerC++2]]></dc:creator><pubDate>Thu, 19 Oct 2006 17:42:26 GMT</pubDate></item><item><title><![CDATA[Reply to Warum funktioniert dieses Programm net?^^ on Thu, 19 Oct 2006 17:50:17 GMT]]></title><description><![CDATA[<p>Schreib anstatt Ergebnis == Zahl1 + Zahl2; mal Ergebnis = Zahl1 + Zahl2;</p>
<p>Und das analog bei den anderen Grundrechenarten auch.</p>
<p>Ein Gleichheitszeichen weist zu, zwei Stück vergleichen.</p>
<p>Ach ja, was passiert, wenn ich 5 oder -8715 bei der Auswahl der Rechenart eingebe <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> <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>
<p>MfG</p>
<p>GPC</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157869</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157869</guid><dc:creator><![CDATA[GPC]]></dc:creator><pubDate>Thu, 19 Oct 2006 17:50:17 GMT</pubDate></item><item><title><![CDATA[Reply to Warum funktioniert dieses Programm net?^^ on Thu, 19 Oct 2006 17:52:17 GMT]]></title><description><![CDATA[<p>Vielen Dank für die schnelle Hilfe, wie gesagt, hab kaum ahnung und versuch mir das auch selbst beizubringen, also c++ <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157870</guid><dc:creator><![CDATA[AnfängerC++2]]></dc:creator><pubDate>Thu, 19 Oct 2006 17:52:17 GMT</pubDate></item><item><title><![CDATA[Reply to Warum funktioniert dieses Programm net?^^ on Thu, 19 Oct 2006 18:33:27 GMT]]></title><description><![CDATA[<p>Und einfacher als if ist der switch befehl</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;cmath&gt;
using namespace std;
int main()
{
  double float Zahl1; // Erste Zahl
  double float Zahl2; // Zweite Zahl
  int Frage; // Siehe 3. cout
  double float Ergebnis; // Ergebnis aus Zahl1 &amp; Zahl 2 (mach ein float rein           //dann kannst komma zahlen benutzen!

  cout &lt;&lt; &quot;Geben Sie die erste Zahl ein&quot; &lt;&lt; endl;
  cin &gt;&gt; Zahl1;
  cout &lt;&lt; &quot;Geben Sie die zweite Zahl ein&quot; &lt;&lt; endl;
  cin &gt;&gt; Zahl2;
  cout &lt;&lt; &quot;Wollen Sie addieren (1) , subtrahieren (2) , multiplizieren (3) oder dividieren(4) ?&quot; &lt;&lt; endl;
  cin &gt;&gt; Frage;
switch (Frage)
{
  case 1:
{
         Ergebnis = Zahl1 + Zahl2;
         cout &lt;&lt; Ergebnis &lt;&lt; endl;
         break;
}
  case 2:
{
         Ergebnis = Zahl1 - Zahl2;
         cout &lt;&lt; Ergebnis &lt;&lt; endl;
         break;
}
  case 3:
{
         Ergebnis = Zahl1 * Zahl2;
         cout &lt;&lt; Ergebnis &lt;&lt; endl;
         break;
}

  case 4: 
{
         Ergebnis = Zahl1 / Zahl2;
         cout &lt;&lt; Ergebnis &lt;&lt; endl;
         break;
}

  default: 
{
         cout&lt;&lt;&quot;ERROR&quot;;   //Falls nix von 1-4 eingetippt wurde ;)
         break;

}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1157886</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157886</guid><dc:creator><![CDATA[Dying]]></dc:creator><pubDate>Thu, 19 Oct 2006 18:33:27 GMT</pubDate></item><item><title><![CDATA[Reply to Warum funktioniert dieses Programm net?^^ on Thu, 19 Oct 2006 18:29:13 GMT]]></title><description><![CDATA[<p>Dying schrieb:</p>
<blockquote>
<p>Und einfacher als if ist der switch befehl</p>
</blockquote>
<p>Wenn man ihn denn anzuwenden weiß. Die Klammern sind über, das ein oder andere break wäre aber nicht schlecht. Und in jedem case ein und dieselbe Ausgabe zu machen, ist auch nicht sonderlich sinnvoll.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157888</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157888</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Thu, 19 Oct 2006 18:29:13 GMT</pubDate></item><item><title><![CDATA[Reply to Warum funktioniert dieses Programm net?^^ on Thu, 19 Oct 2006 18:30:44 GMT]]></title><description><![CDATA[<p>hups habs vergessen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /><br />
aber was wäre wenn man 5 eingäbe <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="😉"
    /><br />
und außerdem find ich das übersichtlicher...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157890</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157890</guid><dc:creator><![CDATA[Dying]]></dc:creator><pubDate>Thu, 19 Oct 2006 18:30:44 GMT</pubDate></item><item><title><![CDATA[Reply to Warum funktioniert dieses Programm net?^^ on Thu, 19 Oct 2006 19:26:14 GMT]]></title><description><![CDATA[<p>Ein wenig gekürzt...</p>
<pre><code class="language-cpp">#include &lt;iostream&gt; 
#include &lt;string&gt; 
#include &lt;cmath&gt; 
#include &lt;conio.h&gt;
using namespace std; 
int main() 
{ 
  double Zahl1, Zahl2; 
  int Frage; 

  cout &lt;&lt; &quot;Geben Sie die erste Zahl ein: &quot; &lt;&lt; endl; 
  cin &gt;&gt; Zahl1; 
  cout &lt;&lt; &quot;Geben Sie die zweite Zahl ein: &quot; &lt;&lt; endl; 
  cin &gt;&gt; Zahl2; 
  cout &lt;&lt; &quot;Rechenoperation:\n1.) Addieren\n2.) Subtrahieren\n3.) Multiplizieren\n4.) Dividieren\nWahl:&quot; &lt;&lt; endl; 
  cin &gt;&gt; Frage; 

switch (Frage){ 
  case 1:{ 
         Zahl1 += Zahl2; 
         break; 
         } 

  case 2:{ 
         Zahl1 -= Zahl2; 
         break; 
         } 

  case 3:{ 
         Zahl1 *= Zahl2; 
         break; 
         } 

  case 4:{ 
         Zahl1 /= Zahl2; 
         break;
         } 

  default:{ 
         Zahl1=0;
         break; 
         } 
}

cout&lt;&lt;&quot;Ergebnis: &quot;&lt;&lt;Zahl1&lt;&lt;endl;
getch();

return 0; 
}
</code></pre>
<p>Dazu solltest du vielleicht auch noch eine Schleife einbauen damit man immer wieder Berechnungen durchführen kann <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>
<p>MfG Kuldren</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157919</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157919</guid><dc:creator><![CDATA[Kuldren]]></dc:creator><pubDate>Thu, 19 Oct 2006 19:26:14 GMT</pubDate></item><item><title><![CDATA[Reply to Warum funktioniert dieses Programm net?^^ on Thu, 19 Oct 2006 22:47:19 GMT]]></title><description><![CDATA[<p>und jetzt die 1337-version:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;conio.h&gt;

using namespace std;

typedef double (*opfunc_t) (const double&amp;, const double&amp;);

double opAdd (const double&amp; op1, const double&amp; op2)
{ return (op1 + op2); }
double opSub (const double&amp; op1, const double&amp; op2)
{ return (op1 - op2); }
double opMul (const double&amp; op1, const double&amp; op2)
{ return (op1 * op2); }
double opDiv (const double&amp; op1, const double&amp; op2)
{ return (op1 / op2); }

struct operator_t
{
    opfunc_t op;
    const char* name;
};

const operator_t operators[] = {
    {opAdd, &quot;Addieren&quot;},
    {opSub, &quot;Subtrahieren&quot;},
    {opMul, &quot;Multiplizieren&quot;},
    {opDiv, &quot;Dividieren&quot;}
};

int main (void)
{
    double op1, op2;
    unsigned int op;

    cout &lt;&lt; &quot;Geben Sie den ersten Operanden ein: &quot; &lt;&lt; endl;
    cin &gt;&gt; op1;
    cout &lt;&lt; &quot;Geben Sie den zweiten Operanden ein: &quot; &lt;&lt; endl;
    cin &gt;&gt; op2;

    cout &lt;&lt; &quot;Rechenoperation:&quot; &lt;&lt; endl;
    for (int n = 0; n &lt; sizeof (operators) / sizeof (operator_t); ++n)
        cout &lt;&lt; n + 1 &lt;&lt; &quot;.) &quot; &lt;&lt; operators[n].name &lt;&lt; endl;
    cout &lt;&lt; &quot;Wahl: &quot;;
    cin &gt;&gt; op;
    --op;
    if (op &gt; sizeof (operators) / sizeof (operator_t))
    {
        cerr &lt;&lt; &quot;Fehler: ungueltige Operation!&quot; &lt;&lt; endl;
        getch ();
        return (1);
    }

    cout &lt;&lt; &quot;Ergebnis: &quot; &lt;&lt; operators[op].op (op1, op2) &lt;&lt; endl;
    getch ();

    return (0);
}
</code></pre>
<p>*scnr*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1158025</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1158025</guid><dc:creator><![CDATA[1338-h4xx0r]]></dc:creator><pubDate>Thu, 19 Oct 2006 22:47:19 GMT</pubDate></item><item><title><![CDATA[Reply to Warum funktioniert dieses Programm net?^^ on Fri, 20 Oct 2006 06:23:36 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Angeber <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>
<p>chrische</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1158069</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1158069</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Fri, 20 Oct 2006 06:23:36 GMT</pubDate></item><item><title><![CDATA[Reply to Warum funktioniert dieses Programm net?^^ on Fri, 20 Oct 2006 07:12:19 GMT]]></title><description><![CDATA[<p>1338-h4xx0r schrieb:</p>
<blockquote>
<p>und jetzt die 1337-version:<br />
...</p>
</blockquote>
<p>Naja, für eine &quot;1337-Version&quot; sind mir da zuviele &quot;op&quot;s drin ... mal für &quot;Operator&quot;, mal für &quot;Operation&quot;, mal für &quot;Operand&quot;, .....<br />
Sowas &quot;operators[op].op (op1, op2)&quot; ist nicht wirklich sprechend.</p>
<p>Außerdem habe ich den &quot;++&quot;-Anteil im C-Programm nicht gefunden.<br />
:p</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1158086</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1158086</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Fri, 20 Oct 2006 07:12:19 GMT</pubDate></item><item><title><![CDATA[Reply to Warum funktioniert dieses Programm net?^^ on Sun, 22 Oct 2006 12:59:45 GMT]]></title><description><![CDATA[<p>Die streams sind doch das ++</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1159049</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1159049</guid><dc:creator><![CDATA[+++]]></dc:creator><pubDate>Sun, 22 Oct 2006 12:59:45 GMT</pubDate></item></channel></rss>