<?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[while schleife.]]></title><description><![CDATA[<p>Hallo,<br />
Kann mir bitte einer erkleren wie While funktioniert ?<br />
Ich hab immer nocht nicht ganz verstanden wie man die abricht .<br />
Mein Beispiel :<br />
Ich will das wenn ich 0 sende das Schleife sich abricht .<br />
Danke</p>
<pre><code class="language-cpp">#include&lt;iostream&gt;
#include&lt;string&gt;

using namespace std;
int rechner();

int main()
{
	int k;
	k = 1;
	while(k != 0)
	{
		rechner();
	}
	return 0;
}

int rechner()
{

	int zahl1;
	int zahl2;
	char zeichen;
	int antwort;
	cout &lt;&lt; &quot;Taschenrechner&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;Um das Programm zu beenden bitte 0 drücken&quot; &lt;&lt; endl;
	cin &gt;&gt; zahl1 &gt;&gt; zeichen &gt;&gt; zahl2 ;

	switch (zeichen)
	{
		case '+' : antwort = zahl1 + zahl2 ; break;
		case '-' : antwort = zahl1 - zahl2 ; break;
		case '*' : antwort = zahl1 * zahl2 ; break;
		case '/' : antwort = zahl1 / zahl2 ; break;
		case ' ' : &quot;Unglücklige eingabe...&quot;; break;
	}	
	cout &lt;&lt; &quot;Antwort: &quot; &lt;&lt; zahl1&lt;&lt; zeichen &lt;&lt; zahl2&lt;&lt; &quot;=&quot;&lt;&lt; antwort&lt;&lt;endl;
	return antwort;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/291305/while-schleife</link><generator>RSS for Node</generator><lastBuildDate>Mon, 17 Aug 2026 19:35:44 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/291305.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 15 Aug 2011 09:06:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to while schleife. on Mon, 15 Aug 2011 09:06:32 GMT]]></title><description><![CDATA[<p>Hallo,<br />
Kann mir bitte einer erkleren wie While funktioniert ?<br />
Ich hab immer nocht nicht ganz verstanden wie man die abricht .<br />
Mein Beispiel :<br />
Ich will das wenn ich 0 sende das Schleife sich abricht .<br />
Danke</p>
<pre><code class="language-cpp">#include&lt;iostream&gt;
#include&lt;string&gt;

using namespace std;
int rechner();

int main()
{
	int k;
	k = 1;
	while(k != 0)
	{
		rechner();
	}
	return 0;
}

int rechner()
{

	int zahl1;
	int zahl2;
	char zeichen;
	int antwort;
	cout &lt;&lt; &quot;Taschenrechner&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;Um das Programm zu beenden bitte 0 drücken&quot; &lt;&lt; endl;
	cin &gt;&gt; zahl1 &gt;&gt; zeichen &gt;&gt; zahl2 ;

	switch (zeichen)
	{
		case '+' : antwort = zahl1 + zahl2 ; break;
		case '-' : antwort = zahl1 - zahl2 ; break;
		case '*' : antwort = zahl1 * zahl2 ; break;
		case '/' : antwort = zahl1 / zahl2 ; break;
		case ' ' : &quot;Unglücklige eingabe...&quot;; break;
	}	
	cout &lt;&lt; &quot;Antwort: &quot; &lt;&lt; zahl1&lt;&lt; zeichen &lt;&lt; zahl2&lt;&lt; &quot;=&quot;&lt;&lt; antwort&lt;&lt;endl;
	return antwort;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2106253</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106253</guid><dc:creator><![CDATA[-ProGresS-]]></dc:creator><pubDate>Mon, 15 Aug 2011 09:06:32 GMT</pubDate></item><item><title><![CDATA[Reply to while schleife. on Mon, 15 Aug 2011 09:25:38 GMT]]></title><description><![CDATA[<p>Du willst mit der Rückgabe von <code>rechner()</code> signalisieren, dass die Schleife abgebrochen werden soll? Dann musst du die Rückgabe auch k zuweisen.</p>
<pre><code class="language-cpp">while(k != 0)
    {
        k=rechner();
    }
</code></pre>
<p>Wenn du k nie änderst, wird die Abbruchbedingung auch nie erfüllt werden...</p>
<p>EDIT: Du musst aber schon noch dafür sorgen, dass die 0 auch irgendwo ankommt. Das sehe ich da noch nicht...</p>
<p>EDIT: Außerdem wäre es unglücklich, die 0 für Abbruch über die normale Rückgabe zu lösen. Da könnte ja auch eine 0 als Rechenergebnis rauskommen. Bastle dafür lieber einen by-reference Parameter oder.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106261</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106261</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Mon, 15 Aug 2011 09:25:38 GMT</pubDate></item><item><title><![CDATA[Reply to while schleife. on Mon, 15 Aug 2011 09:29:21 GMT]]></title><description><![CDATA[<p>Wenn du ein Leerzeichen eingibst, wird erstens antwort überhaupt nicht gesetzt und zweitens heißt es &quot;Unglückliche Eingabe&quot;.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106265</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106265</guid><dc:creator><![CDATA[wxSkip]]></dc:creator><pubDate>Mon, 15 Aug 2011 09:29:21 GMT</pubDate></item><item><title><![CDATA[Reply to while schleife. on Thu, 18 Aug 2011 02:13:09 GMT]]></title><description><![CDATA[<p>Danke für Ihre Hilfe <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 />
Weiß jetzt alles darüber was ich wissen wohlte</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2107429</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2107429</guid><dc:creator><![CDATA[-ProGresS-]]></dc:creator><pubDate>Thu, 18 Aug 2011 02:13:09 GMT</pubDate></item></channel></rss>