<?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[Problem mit Endlosschleife]]></title><description><![CDATA[<p>Moin,</p>
<p>ich habe ein Problem bei meinen Programm zur Berechnung eines max. Volumen eines quadr. Kastens.<br />
Und zwar soll die Seitenlänge L eingegeben werden.<br />
Danach soll die Höhe x schrittweise, bis zu einem sinnvollen maximal Wert, erhöht werden.<br />
Und in dieser For-Schleife soll das max Volumen mit dem dazugehörigen x-wert gespeichert werden.</p>
<p>Und wenn ich mein Programm jetzt ausführe, bekomme ich eine Endlosschleife raus, die mir immer wieder 0 ausgibt. Wo liegt das Problem?</p>
<p>Danke an euch!</p>
<pre><code class="language-cpp">#include &lt;QtCore/QCoreApplication&gt;
#include &lt;iostream&gt;
#include &lt;cmath&gt;
using namespace std;

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

        double V, Vmax, x, xmax, L;
        Vmax = 0;
        xmax = 0;

        cout &lt;&lt; &quot;Bitte geben Sie einen Wert fuer die Seitenlaenge L ein&quot; &lt;&lt; endl; // einlesen der Kantenlänge
        cin &gt;&gt; L;

        for (x = 0,01; x &lt; (L/2); x = x+0,01)
        {

            V = x *((L-(2*x))*(L-(2*x)));

            if (Vmax &lt; V)

             {
                Vmax = V;
                xmax = x;

             }

            cout &lt;&lt; &quot;Das maximale Volumen betraegt: &quot; &lt;&lt; Vmax &lt;&lt; endl;
            cout &lt;&lt; &quot;Die dazugehoerige Kastenhoahe betraegt: &quot; &lt;&lt; xmax &lt;&lt; endl;
         }

     return a.exec();
 }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/276678/problem-mit-endlosschleife</link><generator>RSS for Node</generator><lastBuildDate>Wed, 26 Aug 2026 07:31:58 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/276678.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 06 Nov 2010 15:18:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit Endlosschleife on Sat, 06 Nov 2010 15:18:41 GMT]]></title><description><![CDATA[<p>Moin,</p>
<p>ich habe ein Problem bei meinen Programm zur Berechnung eines max. Volumen eines quadr. Kastens.<br />
Und zwar soll die Seitenlänge L eingegeben werden.<br />
Danach soll die Höhe x schrittweise, bis zu einem sinnvollen maximal Wert, erhöht werden.<br />
Und in dieser For-Schleife soll das max Volumen mit dem dazugehörigen x-wert gespeichert werden.</p>
<p>Und wenn ich mein Programm jetzt ausführe, bekomme ich eine Endlosschleife raus, die mir immer wieder 0 ausgibt. Wo liegt das Problem?</p>
<p>Danke an euch!</p>
<pre><code class="language-cpp">#include &lt;QtCore/QCoreApplication&gt;
#include &lt;iostream&gt;
#include &lt;cmath&gt;
using namespace std;

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

        double V, Vmax, x, xmax, L;
        Vmax = 0;
        xmax = 0;

        cout &lt;&lt; &quot;Bitte geben Sie einen Wert fuer die Seitenlaenge L ein&quot; &lt;&lt; endl; // einlesen der Kantenlänge
        cin &gt;&gt; L;

        for (x = 0,01; x &lt; (L/2); x = x+0,01)
        {

            V = x *((L-(2*x))*(L-(2*x)));

            if (Vmax &lt; V)

             {
                Vmax = V;
                xmax = x;

             }

            cout &lt;&lt; &quot;Das maximale Volumen betraegt: &quot; &lt;&lt; Vmax &lt;&lt; endl;
            cout &lt;&lt; &quot;Die dazugehoerige Kastenhoahe betraegt: &quot; &lt;&lt; xmax &lt;&lt; endl;
         }

     return a.exec();
 }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1976122</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1976122</guid><dc:creator><![CDATA[fynkah]]></dc:creator><pubDate>Sat, 06 Nov 2010 15:18:41 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit Endlosschleife on Sat, 06 Nov 2010 15:23:03 GMT]]></title><description><![CDATA[<p>Lustiger Fehler .... Fließkommazahlen schreibt man fast überall auf der WElt (und auch in C++) mit Punkt und nicht (wie in Deutschland) mit Komma.</p>
<p>Der Komma-Operator hat dagegen eine eigene Bedeutung.</p>
<p>Das hier ist ein gutes Beispiel dafür, dass &quot;Kompilierbar&quot; nicht &quot;richtig&quot; bedeutet. <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>Gruß,</p>
<p>Simon2.</p>
<p>P.S.: Könnte es sein, dass der Compiler eine Warnung ausgespuckt hat, die du aber ignoriert hast?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1976125</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1976125</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Sat, 06 Nov 2010 15:23:03 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit Endlosschleife on Sat, 06 Nov 2010 15:52:52 GMT]]></title><description><![CDATA[<p>QT hat nur so ein ! ausgespuckt, aber ohne Erklärung.</p>
<p>Danke für deine Hilfe:)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1976145</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1976145</guid><dc:creator><![CDATA[fynkah]]></dc:creator><pubDate>Sat, 06 Nov 2010 15:52:52 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit Endlosschleife on Sat, 06 Nov 2010 20:01:08 GMT]]></title><description><![CDATA[<p>OK - mit QT kenne ich mich nicht aus.</p>
<p>Ich hoffe, du kommst jetzt klar.</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1976321</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1976321</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Sat, 06 Nov 2010 20:01:08 GMT</pubDate></item></channel></rss>