<?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[C++ if else problem]]></title><description><![CDATA[<p>Hey Leute, ich bin neu hier im Forum!<br />
Wir fingen dieses Jahr an mit C++.<br />
Nun wollte ich zuhause mal ein Programm schreiben, dass eine Rechenaufgabe beinhaltet die man lösen sollte.<br />
Jedoch scheitere ich am IF-ELSE und ich weiß nicht wo der fehler liegt!<br />
Hier der Sourcecode:</p>
<p>#include &lt;iostream&gt;</p>
<p>using namespace std;</p>
<p>int main()<br />
{<br />
int loesung;</p>
<p>cout &lt;&lt;&quot;Rechentest:&quot;&lt;&lt;endl&lt;&lt;endl&lt;&lt;endl;<br />
cout &lt;&lt;&quot;43*5=?&quot;;<br />
cin &gt;&gt;loesung;<br />
if(loesung = 215);<br />
cout &lt;&lt;&quot;Gut gemacht!&quot;&lt;&lt;endl;<br />
else<br />
cout &lt;&lt;&quot;Falsche Antwort! - Versuchs nochmal!&quot;&lt;&lt;endl;</p>
<p>system(&quot;PAUSE&quot;);<br />
return EXIT_SUCCESS;<br />
}</p>
<p>----------<br />
Eigentlich wollte ich noch was dazu machen, dass es die Funktion, also im fall &quot;else&quot; wieder aufruft, um die Rechnung nochmals zu versuchen, weiß ich aber nicht wie, aber wenn´s hier sowieso schon scheitert...</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/123507/c-if-else-problem</link><generator>RSS for Node</generator><lastBuildDate>Sun, 23 Aug 2026 14:58:33 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/123507.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 17 Oct 2005 15:53:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to C++ if else problem on Mon, 17 Oct 2005 15:53:11 GMT]]></title><description><![CDATA[<p>Hey Leute, ich bin neu hier im Forum!<br />
Wir fingen dieses Jahr an mit C++.<br />
Nun wollte ich zuhause mal ein Programm schreiben, dass eine Rechenaufgabe beinhaltet die man lösen sollte.<br />
Jedoch scheitere ich am IF-ELSE und ich weiß nicht wo der fehler liegt!<br />
Hier der Sourcecode:</p>
<p>#include &lt;iostream&gt;</p>
<p>using namespace std;</p>
<p>int main()<br />
{<br />
int loesung;</p>
<p>cout &lt;&lt;&quot;Rechentest:&quot;&lt;&lt;endl&lt;&lt;endl&lt;&lt;endl;<br />
cout &lt;&lt;&quot;43*5=?&quot;;<br />
cin &gt;&gt;loesung;<br />
if(loesung = 215);<br />
cout &lt;&lt;&quot;Gut gemacht!&quot;&lt;&lt;endl;<br />
else<br />
cout &lt;&lt;&quot;Falsche Antwort! - Versuchs nochmal!&quot;&lt;&lt;endl;</p>
<p>system(&quot;PAUSE&quot;);<br />
return EXIT_SUCCESS;<br />
}</p>
<p>----------<br />
Eigentlich wollte ich noch was dazu machen, dass es die Funktion, also im fall &quot;else&quot; wieder aufruft, um die Rechnung nochmals zu versuchen, weiß ich aber nicht wie, aber wenn´s hier sowieso schon scheitert...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/894289</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/894289</guid><dc:creator><![CDATA[XaTrIxX]]></dc:creator><pubDate>Mon, 17 Oct 2005 15:53:11 GMT</pubDate></item><item><title><![CDATA[Reply to C++ if else problem on Mon, 17 Oct 2005 15:59:39 GMT]]></title><description><![CDATA[<p>= != ==</p>
<p>// edit<br />
wozu quälst du dich mit &lt;&lt;endl&lt;&lt;endl&lt;&lt;endl statt einfach cout &lt;&lt;&quot;Rechentest:\n\n\n&quot; zu schreiben</p>
]]></description><link>https://www.c-plusplus.net/forum/post/894292</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/894292</guid><dc:creator><![CDATA[shapeless]]></dc:creator><pubDate>Mon, 17 Oct 2005 15:59:39 GMT</pubDate></item><item><title><![CDATA[Reply to C++ if else problem on Mon, 17 Oct 2005 15:58:14 GMT]]></title><description><![CDATA[<p>Das Problem liegt in der Zeile:</p>
<pre><code class="language-cpp">if(loesung = 215);
</code></pre>
<p>hier hast du gleich zwei Fehler versteckt:</p>
<p>1. Gehört das ';' nach der Klammer nicht dorthin, sosnt würde (nach ordentlicher Formatierung das hier getan werden:</p>
<pre><code class="language-cpp">if(...)
    ;
cout &lt;&lt;&quot;Gut gemacht!&quot;&lt;&lt;endl; // Wird auf jeden Fall ausgegeben
else // Syntax-Fehler
    cout &lt;&lt;&quot;Falsche Antwort! - Versuchs nochmal!&quot;&lt;&lt;endl;
</code></pre>
<p>2. Du hast statt dem Vergleichsoperator (==) den Zuweisungsoperator (=) benützt, die zeile sollte also korrekt so aussehen:</p>
<pre><code class="language-cpp">if(loesung == 215)
</code></pre>
<p>MfG SideWinder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/894295</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/894295</guid><dc:creator><![CDATA[SideWinder]]></dc:creator><pubDate>Mon, 17 Oct 2005 15:58:14 GMT</pubDate></item><item><title><![CDATA[Reply to C++ if else problem on Mon, 17 Oct 2005 16:05:39 GMT]]></title><description><![CDATA[<p>ach, dann hat das semikolon eigentlich auch eine besondere funktion.<br />
unser lehrer schlicht und einfach: nach jeder zeile ein semikolon!<br />
lol okay ganz versteh ich den zusammenhang noch nicht aber danke!<br />
vergleichsoperator! eh klar...<br />
nun noch: falls loesung falsch, nochmal von vorne....wie rufe ich die funktion nochmal auf?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/894302</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/894302</guid><dc:creator><![CDATA[XaTrIxX]]></dc:creator><pubDate>Mon, 17 Oct 2005 16:05:39 GMT</pubDate></item><item><title><![CDATA[Reply to C++ if else problem on Mon, 17 Oct 2005 16:13:56 GMT]]></title><description><![CDATA[<p>Mach aus dem else cout &lt;&lt;&quot;Falsche Antwort! - Versuchs nochmal!&quot;&lt;&lt;endl;</p>
<p>ein</p>
<pre><code class="language-cpp">else
{
    cout &lt;&lt;&quot;Falsche Antwort! - Versuchs nochmal!&quot;&lt;&lt;endl;
    main();
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/894305</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/894305</guid><dc:creator><![CDATA[...]]></dc:creator><pubDate>Mon, 17 Oct 2005 16:13:56 GMT</pubDate></item><item><title><![CDATA[Reply to C++ if else problem on Mon, 17 Oct 2005 16:17:33 GMT]]></title><description><![CDATA[<p>Darf man main() nochmal aufrufen?</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/10469">@XaTrIxX</a>: Nach jeder Anweisung gehört ein Semikolon, nicht nach jeder Zeile (dann brauch ich auch gleich gar keins, das Zeilenende findet man auch so)</p>
<p>MfG SideWinder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/894309</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/894309</guid><dc:creator><![CDATA[SideWinder]]></dc:creator><pubDate>Mon, 17 Oct 2005 16:17:33 GMT</pubDate></item><item><title><![CDATA[Reply to C++ if else problem on Mon, 17 Oct 2005 16:35:08 GMT]]></title><description><![CDATA[<p>ah danke einfach mit main(); hab ich mir gedacht! ty</p>
]]></description><link>https://www.c-plusplus.net/forum/post/894320</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/894320</guid><dc:creator><![CDATA[XaTrIxX]]></dc:creator><pubDate>Mon, 17 Oct 2005 16:35:08 GMT</pubDate></item><item><title><![CDATA[Reply to C++ if else problem on Mon, 17 Oct 2005 16:53:00 GMT]]></title><description><![CDATA[<p>SideWinder schrieb:</p>
<blockquote>
<p>Darf man main() nochmal aufrufen?</p>
</blockquote>
<p>Was spricht dagegen? Obwohl ich hier definitiv eine do... while bevorzugen würde <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61b.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_tongue"
      title=":P"
      alt="😛"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/894334</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/894334</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Mon, 17 Oct 2005 16:53:00 GMT</pubDate></item><item><title><![CDATA[Reply to C++ if else problem on Mon, 17 Oct 2005 16:57:37 GMT]]></title><description><![CDATA[<p>TactX schrieb:</p>
<blockquote>
<p>Was spricht dagegen?</p>
</blockquote>
<p>Dass nach zu vielen falschen Antworten der Stack überläuft. Das ist IMHO hier noch übler, als ein goto zu benutzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/894338</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/894338</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Mon, 17 Oct 2005 16:57:37 GMT</pubDate></item><item><title><![CDATA[Reply to C++ if else problem on Mon, 17 Oct 2005 17:11:42 GMT]]></title><description><![CDATA[<p>Den will ich sehen, der das Programm so lange benutzt bis der Stack überläuft <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/894352</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/894352</guid><dc:creator><![CDATA[User---]]></dc:creator><pubDate>Mon, 17 Oct 2005 17:11:42 GMT</pubDate></item><item><title><![CDATA[Reply to C++ if else problem on Mon, 17 Oct 2005 17:46:57 GMT]]></title><description><![CDATA[<p>MFK schrieb:</p>
<blockquote>
<p>TactX schrieb:</p>
<blockquote>
<p>Was spricht dagegen?</p>
</blockquote>
<p>Dass nach zu vielen falschen Antworten der Stack überläuft. Das ist IMHO hier noch übler, als ein goto zu benutzen.</p>
</blockquote>
<p>Ich meinte das eher prinzipiell. Und außerdem muss ich User-- da beipflichten <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/894408</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/894408</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Mon, 17 Oct 2005 17:46:57 GMT</pubDate></item><item><title><![CDATA[Reply to C++ if else problem on Mon, 17 Oct 2005 17:53:15 GMT]]></title><description><![CDATA[<p>TactX schrieb:</p>
<blockquote>
<p>Ich meinte das eher prinzipiell.</p>
</blockquote>
<p>Ich auch. Mir ist klar, dass da kein User so lange falsche Ergebnisse eingibt, bis es knallt.</p>
<p>Ich bin der Meinung, dass man Rekursion als Schleifenersatz nur dann benutzen sollte, wenn man den Abbruch innerhalb der Stackgrenzen garantieren kann und eine Schleife zu umständlich wäre. Keinesfalls sollte sich das ein Anfänger als &quot;best practice&quot; angewöhnen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/894412</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/894412</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Mon, 17 Oct 2005 17:53:15 GMT</pubDate></item><item><title><![CDATA[Reply to C++ if else problem on Mon, 17 Oct 2005 18:30:46 GMT]]></title><description><![CDATA[<p>XaTrIxX schrieb:</p>
<blockquote>
<p>ah danke einfach mit main(); hab ich mir gedacht! ty</p>
</blockquote>
<p>Vergiss das ganz schnell !!!</p>
<p>Wenn dein Lehrer das Programm sieht un du ihm sagst das wir das hier mit main() gesagt haben ist unser Ruf ganz schnell hin ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/894454</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/894454</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Mon, 17 Oct 2005 18:30:46 GMT</pubDate></item><item><title><![CDATA[Reply to C++ if else problem on Mon, 17 Oct 2005 22:38:03 GMT]]></title><description><![CDATA[<p>dafür gibt es ja schließlich schleifen.<br />
das mit dem semikolon ist auch logisch.<br />
wenn du es setzt dann gehört das else nicht mehr zum if sondern wird als EINE EINZELNE anweisung angesehen.</p>
<p>ps: lernt man heute eigentlich nicht mehr mit leerzeichen zu schreiben?</p>
<pre><code class="language-cpp">cout&lt;&lt;&quot;Wenn das mal nicht ganz toll\nübersichtlich ist&quot;&lt;&lt;endl&lt;&lt;endl&lt;&lt;&quot;Und noch eine Zeile wenn man mag&quot;&lt;&lt;endl&lt;&lt;endl&lt;&lt;&quot;Der Schluss fehlt noch&quot;&lt;&lt;endl&lt;&lt;endl&lt;&lt;endl&lt;&lt;&quot;Doch noch nicht genug\n\n\n&quot;&lt;&lt;endl&lt;&lt;endl&lt;&lt;endl;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/894631</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/894631</guid><dc:creator><![CDATA[schleifi]]></dc:creator><pubDate>Mon, 17 Oct 2005 22:38:03 GMT</pubDate></item><item><title><![CDATA[Reply to C++ if else problem on Mon, 17 Oct 2005 22:51:29 GMT]]></title><description><![CDATA[<p>TactX schrieb:</p>
<blockquote>
<p>SideWinder schrieb:</p>
<blockquote>
<p>Darf man main() nochmal aufrufen?</p>
</blockquote>
<p>Was spricht dagegen?</p>
</blockquote>
<p>standard 3.6.1.3<br />
the funtion main shall not be used within the program. ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/894635</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/894635</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Mon, 17 Oct 2005 22:51:29 GMT</pubDate></item><item><title><![CDATA[Reply to C++ if else problem on Tue, 18 Oct 2005 12:25:18 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>TactX schrieb:</p>
<blockquote>
<p>SideWinder schrieb:</p>
<blockquote>
<p>Darf man main() nochmal aufrufen?</p>
</blockquote>
<p>Was spricht dagegen?</p>
</blockquote>
<p>standard 3.6.1.3<br />
the funtion main shall not be used within the program. ...</p>
</blockquote>
<p>Tatsache. Danke für die Info.</p>
<p>OT: Gilt das auch für C? Da habe ich nämlich nichts gefunden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/895061</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/895061</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Tue, 18 Oct 2005 12:25:18 GMT</pubDate></item></channel></rss>