<?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[Verständnis Frage (If vs. While)]]></title><description><![CDATA[<p>Gegeben:</p>
<p>i = 0<br />
z = 10</p>
<p>i wird (wenn Button pressed) immer um i++ hochgezählt, bis i&lt;=z ist.<br />
Für das Problem habe ich zwei Algorithmen (btw: Nennt man es Algorithmen?^^)<br />
&quot;entwickelt&quot;^^<br />
<strong>Wo liegt hier der Unterschied ? Kann man beide verwenden ?</strong></p>
<pre><code class="language-cpp">//Variante 1
if (i &lt;= z)
      {i++;}

//Variante 2
while (i &lt;= z)
      {i++;} 

/* Ich persönlich, finde Variante 2 logischer. Was meint ihr ? */
</code></pre>
<p>(Mein C++ Builder funktioniert wieder mal nicht. installiere es gerade neu,<br />
deshalb möchte ich es jetzt schon mal wissen. THX :D)</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/294740/verständnis-frage-if-vs-while</link><generator>RSS for Node</generator><lastBuildDate>Sat, 15 Aug 2026 19:02:54 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/294740.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 31 Oct 2011 16:39:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Verständnis Frage (If vs. While) on Mon, 31 Oct 2011 16:39:00 GMT]]></title><description><![CDATA[<p>Gegeben:</p>
<p>i = 0<br />
z = 10</p>
<p>i wird (wenn Button pressed) immer um i++ hochgezählt, bis i&lt;=z ist.<br />
Für das Problem habe ich zwei Algorithmen (btw: Nennt man es Algorithmen?^^)<br />
&quot;entwickelt&quot;^^<br />
<strong>Wo liegt hier der Unterschied ? Kann man beide verwenden ?</strong></p>
<pre><code class="language-cpp">//Variante 1
if (i &lt;= z)
      {i++;}

//Variante 2
while (i &lt;= z)
      {i++;} 

/* Ich persönlich, finde Variante 2 logischer. Was meint ihr ? */
</code></pre>
<p>(Mein C++ Builder funktioniert wieder mal nicht. installiere es gerade neu,<br />
deshalb möchte ich es jetzt schon mal wissen. THX :D)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138337</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138337</guid><dc:creator><![CDATA[marko_XY_WHT?]]></dc:creator><pubDate>Mon, 31 Oct 2011 16:39:00 GMT</pubDate></item><item><title><![CDATA[Reply to Verständnis Frage (If vs. While) on Mon, 31 Oct 2011 16:40:37 GMT]]></title><description><![CDATA[<p>ist das die if-Schleife?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138339</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138339</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Mon, 31 Oct 2011 16:40:37 GMT</pubDate></item><item><title><![CDATA[Reply to Verständnis Frage (If vs. While) on Mon, 31 Oct 2011 16:43:09 GMT]]></title><description><![CDATA[<p><code>if</code> bedeutet &quot;wenn&quot;. <code>while</code> bedeutet &quot;solange&quot;.</p>
<p>Bei <code>if</code> wird der Code in geschweiften Klammern so lange ausgeführt, <em>wenn</em> die Bedingung in den runden Klammern zutrifft. Bei <code>while</code> wird der Code in geschweiften Klammern so lange ausgeführt, <em>so lange</em> die Bedingung in den runden Klammern zutrifft.</p>
<p>marko_XY_WHT? schrieb:</p>
<blockquote>
<p>i wird (wenn Button pressed) immer um i++ hochgezählt, bis i&lt;=z ist.</p>
</blockquote>
<p>Btw. so lange du nicht von C++ einigermaßen Ahnung hast, würde ich die Finger von GUI-Programmierung lassen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138340</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138340</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Mon, 31 Oct 2011 16:43:09 GMT</pubDate></item><item><title><![CDATA[Reply to Verständnis Frage (If vs. While) on Mon, 31 Oct 2011 16:49:24 GMT]]></title><description><![CDATA[<p>ProgChild schrieb:</p>
<blockquote>
<p>Bei <code>if</code> wird der Code in geschweiften Klammern so lange ausgeführt, <em>wenn</em> die Bedingung in den runden Klammern zutrifft. Bei <code>while</code> wird der Code in geschweiften Klammern so lange ausgeführt, <em>so lange</em> die Bedingung in den runden Klammern zutrifft.</p>
</blockquote>
<p>Das war jetzt aber ungeschickt formuliert <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="😃"
    /> . Ich korrigiere mal:</p>
<p>Bei <code>if</code> wird der Code in geschweiften Klammern <s>so lange</s> ausgeführt, <em>wenn</em> die Bedingung in den runden Klammern zutrifft. Bei <code>while</code> wird der Code in geschweiften Klammern so lange ausgeführt, <em>so lange</em> die Bedingung in den runden Klammern zutrifft.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138345</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138345</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 31 Oct 2011 16:49:24 GMT</pubDate></item><item><title><![CDATA[Reply to Verständnis Frage (If vs. While) on Mon, 31 Oct 2011 16:50:43 GMT]]></title><description><![CDATA[<p>ProgChild schrieb:</p>
<blockquote>
<p>Bei if wird der Code in geschweiften Klammern so lange ausgeführt, wenn die Bedingung in den runden Klammern zutrifft. Bei while…</p>
</blockquote>
<p>Ist etwas unverständliche. Du meintest sicher: &quot; Bei if wird der Code in geschweiften Klammern <strong>einmalig</strong> ausgeführt, wenn die Bedingung in den runden Klammern zutrifft. Bei while…&quot;<br />
Gruß</p>
<p>zu spät</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138347</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138347</guid><dc:creator><![CDATA[Helmut.Jakoby]]></dc:creator><pubDate>Mon, 31 Oct 2011 16:50:43 GMT</pubDate></item><item><title><![CDATA[Reply to Verständnis Frage (If vs. While) on Mon, 31 Oct 2011 16:51:15 GMT]]></title><description><![CDATA[<p>ProgChild schrieb:</p>
<blockquote>
<p>Bei <code>if</code> wird der Code in geschweiften Klammern <s>so lange</s> ausgeführt, <em>wenn</em> die Bedingung in den runden Klammern zutrifft. [...]</p>
</blockquote>
<p>denn der Code wird nur einmal ausgeführt. Der if-Block ist <strong>keine</strong> Schleife.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138348</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138348</guid><dc:creator><![CDATA[*Rewind*]]></dc:creator><pubDate>Mon, 31 Oct 2011 16:51:15 GMT</pubDate></item><item><title><![CDATA[Reply to Verständnis Frage (If vs. While) on Mon, 31 Oct 2011 17:08:43 GMT]]></title><description><![CDATA[<p>Seht ihr, schon sind alle anderer Meinung. Da wundert es mich nicht, wenn ich<br />
auch durcheinander komme <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>
<p>Ne jetzt im ernst: Ich verstehe schon, was die If Bedingung und die While<br />
Schleife so machen. Aber bzgl. meines Programms, sind doch beide Varianten<br />
in Ordnung, nicht ?</p>
<p>Es ist ja blubb, ob man um i++ erhöht, wenn i &lt;= z ist oder um i++<br />
erhöht solange i &lt;= z ist ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138356</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138356</guid><dc:creator><![CDATA[marko_XY_WHT?]]></dc:creator><pubDate>Mon, 31 Oct 2011 17:08:43 GMT</pubDate></item><item><title><![CDATA[Reply to Verständnis Frage (If vs. While) on Mon, 31 Oct 2011 17:12:10 GMT]]></title><description><![CDATA[<p>Ich dachte, du möchtest, dass <code>i</code> bis 10 bzw. <code>z</code> hochgezählt wird und nicht nur um eins erhöht wird... in dem Fall würde die <code>if</code> -Abfrage aus dem genannten Grund nicht passen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138358</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138358</guid><dc:creator><![CDATA[*Rewind*]]></dc:creator><pubDate>Mon, 31 Oct 2011 17:12:10 GMT</pubDate></item><item><title><![CDATA[Reply to Verständnis Frage (If vs. While) on Mon, 31 Oct 2011 17:13:21 GMT]]></title><description><![CDATA[<p>Wenn du denkst, dass das das Gleiche wäre, hast du offen gesagt gar nichts verstanden. Mal ein Beispiel:</p>
<pre><code class="language-cpp">int main()
{
  int i = 0;
  if (i &lt; 10)
    ++i;
  // i hat jetzt den Wert 1
}
</code></pre>
<pre><code class="language-cpp">int main()
{
  int i = 0;
  while (i &lt; 10)
    ++i;
  // i hat jetzt den Wert 10
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2138359</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138359</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Mon, 31 Oct 2011 17:13:21 GMT</pubDate></item><item><title><![CDATA[Reply to Verständnis Frage (If vs. While) on Mon, 31 Oct 2011 17:13:55 GMT]]></title><description><![CDATA[<p>Nein Mann if ist keine Schleife. Der Block wird höchstens einmal ausgeführt. Es ist nicht das gleiche wie bei der while-Alternative</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138360</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138360</guid><dc:creator><![CDATA[lolalter]]></dc:creator><pubDate>Mon, 31 Oct 2011 17:13:55 GMT</pubDate></item><item><title><![CDATA[Reply to Verständnis Frage (If vs. While) on Mon, 31 Oct 2011 17:17:33 GMT]]></title><description><![CDATA[<p>Das wäre also richtig?:</p>
<p>Bei If wird es nur um 1 erhöht und das wars dann auch schon.<br />
und bei while wird es so lange erhöht, bis es &lt;=z ist!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138362</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138362</guid><dc:creator><![CDATA[marko_XY_WHT?]]></dc:creator><pubDate>Mon, 31 Oct 2011 17:17:33 GMT</pubDate></item><item><title><![CDATA[Reply to Verständnis Frage (If vs. While) on Mon, 31 Oct 2011 17:19:04 GMT]]></title><description><![CDATA[<p>marko_XY_WHT? schrieb:</p>
<blockquote>
<p>Das wäre also richtig?:</p>
<p>Bei If wird es nur um 1 erhöht und das wars dann auch schon.<br />
und bei while wird es so lange erhöht, bis es &lt;=z ist!</p>
</blockquote>
<p>jop!<br />
schau dir trotzdem lieber die Grundlagen nochmal an und siehe zu,<br />
dass dein Builder wieder funktioniert. Sonst wird es katastrophal <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/2138363</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138363</guid><dc:creator><![CDATA[robbystrike]]></dc:creator><pubDate>Mon, 31 Oct 2011 17:19:04 GMT</pubDate></item><item><title><![CDATA[Reply to Verständnis Frage (If vs. While) on Mon, 31 Oct 2011 17:20:22 GMT]]></title><description><![CDATA[<p>Lies bitte ein Buch, bevor du solche Fragen stellst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138364</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138364</guid><dc:creator><![CDATA[*Rewind*]]></dc:creator><pubDate>Mon, 31 Oct 2011 17:20:22 GMT</pubDate></item><item><title><![CDATA[Reply to Verständnis Frage (If vs. While) on Mon, 31 Oct 2011 17:21:11 GMT]]></title><description><![CDATA[<p>robbystrike schrieb:</p>
<blockquote>
<p>marko_XY_WHT? schrieb:</p>
<blockquote>
<p>Das wäre also richtig?:</p>
<p>Bei If wird es nur um 1 erhöht und das wars dann auch schon.<br />
und bei while wird es so lange erhöht, bis es &lt;=z ist!</p>
</blockquote>
<p>jop!</p>
</blockquote>
<p>Nö. Es wird so lange erhöht, bis es &gt; z ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138365</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138365</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Mon, 31 Oct 2011 17:21:11 GMT</pubDate></item></channel></rss>