<?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[Probelm bei do while Schleife]]></title><description><![CDATA[<p>Hallo,<br />
ich bin neu sowohl bei C++ als auch hier im Forum. Ich habe mich an einem Programm versucht das ich als Hausaufgabe bekommen habe, jedoch habe ich ein Problem bei der do while Schleife. Das ist was ich genau machen muss:<br />
&quot;Für n Materialien werden folgende Eingangsdaten gelesen:<br />
Name, Anfangsstock, Eingang und Ausgang. Wenn der eingegebene Ausgang größer ist als die Summe von Anfangsstock und Eingang soll eine Fehlermeldung erfolgen und ein neuer Wert für den Ausgang von der Tastatur gelesen werden. Dies erfolgt so lange bis man einen korrekten Wert eingibt, so dass Anfangsstock+Eingang-Ausgang&gt;=0. Man berechnet den Endstock als Anfangsstock+Eingang-Ausgang.&quot;</p>
<p>Meine do while Schleife macht jedoch nur einmal die Fehlermeldung, auch wenn ich danach noch eine Zahl angebe die dann die Bedingung Anfangsstock+Eingang-Ausgang&gt;=0 erfüllt.</p>
<p>Kann mir bitte jemand erklären wieso?<br />
Danke</p>
<pre><code>#include&lt;iostream&gt;
#include&lt;conio.h&gt;
#include&lt;string&gt;

using namespace std;

struct Materialien
{
	string name;
	int aus, ein, as, end;
};

int main() 
{
	Materialien Mat[100];
	int n;
	cout&lt;&lt;&quot;Geben Sie die Zahl der Materialien ein:&quot;; cin&gt;&gt;n; 
	for(int i=0;i&lt;n;i++) 
		{ 
			cout&lt;&lt;&quot;Name von Material &quot;&lt;&lt;i+1&lt;&lt;&quot; : &quot;;cin&gt;&gt;Mat[i].name; 
			cout&lt;&lt;&quot;Anfangsstock: &quot;;cin&gt;&gt;Mat[i].as; 
			cout&lt;&lt;&quot;Eingang: &quot;;cin&gt;&gt;Mat[i].ein; 
			cout&lt;&lt;&quot;Ausgang: &quot;;cin&gt;&gt;Mat[i].aus;

			do{        
						cout&lt;&lt;&quot;ERROR&quot;&lt;&lt;endl;
						cout&lt;&lt;&quot;Geben Sie einen neuen Ausgang ein: &quot;;cin&gt;&gt;Mat[i].aus;

				 }while((Mat[i].as+Mat[i].ein-Mat[i].aus)&gt;=0);
		} 

	for(int i=0;i&lt;n;i++) 
		{ 
			cout&lt;&lt;&quot;Name von Material &quot;&lt;&lt;i+1&lt;&lt;&quot; : &quot;&lt;&lt;Mat[i].name&lt;&lt;endl; 
			cout&lt;&lt;&quot;Anfangsstock: &quot;&lt;&lt;Mat[i].as&lt;&lt;endl; 
			cout&lt;&lt;&quot;Eingang: &quot;&lt;&lt;Mat[i].ein&lt;&lt;endl; 
			cout&lt;&lt;&quot;Ausgang: &quot;&lt;&lt;Mat[i].aus&lt;&lt;endl;

		}

	_getch();
	return 0;

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/335591/probelm-bei-do-while-schleife</link><generator>RSS for Node</generator><lastBuildDate>Fri, 24 Apr 2026 12:16:00 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/335591.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 28 Nov 2015 13:40:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Probelm bei do while Schleife on Sat, 28 Nov 2015 13:46:38 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich bin neu sowohl bei C++ als auch hier im Forum. Ich habe mich an einem Programm versucht das ich als Hausaufgabe bekommen habe, jedoch habe ich ein Problem bei der do while Schleife. Das ist was ich genau machen muss:<br />
&quot;Für n Materialien werden folgende Eingangsdaten gelesen:<br />
Name, Anfangsstock, Eingang und Ausgang. Wenn der eingegebene Ausgang größer ist als die Summe von Anfangsstock und Eingang soll eine Fehlermeldung erfolgen und ein neuer Wert für den Ausgang von der Tastatur gelesen werden. Dies erfolgt so lange bis man einen korrekten Wert eingibt, so dass Anfangsstock+Eingang-Ausgang&gt;=0. Man berechnet den Endstock als Anfangsstock+Eingang-Ausgang.&quot;</p>
<p>Meine do while Schleife macht jedoch nur einmal die Fehlermeldung, auch wenn ich danach noch eine Zahl angebe die dann die Bedingung Anfangsstock+Eingang-Ausgang&gt;=0 erfüllt.</p>
<p>Kann mir bitte jemand erklären wieso?<br />
Danke</p>
<pre><code>#include&lt;iostream&gt;
#include&lt;conio.h&gt;
#include&lt;string&gt;

using namespace std;

struct Materialien
{
	string name;
	int aus, ein, as, end;
};

int main() 
{
	Materialien Mat[100];
	int n;
	cout&lt;&lt;&quot;Geben Sie die Zahl der Materialien ein:&quot;; cin&gt;&gt;n; 
	for(int i=0;i&lt;n;i++) 
		{ 
			cout&lt;&lt;&quot;Name von Material &quot;&lt;&lt;i+1&lt;&lt;&quot; : &quot;;cin&gt;&gt;Mat[i].name; 
			cout&lt;&lt;&quot;Anfangsstock: &quot;;cin&gt;&gt;Mat[i].as; 
			cout&lt;&lt;&quot;Eingang: &quot;;cin&gt;&gt;Mat[i].ein; 
			cout&lt;&lt;&quot;Ausgang: &quot;;cin&gt;&gt;Mat[i].aus;

			do{        
						cout&lt;&lt;&quot;ERROR&quot;&lt;&lt;endl;
						cout&lt;&lt;&quot;Geben Sie einen neuen Ausgang ein: &quot;;cin&gt;&gt;Mat[i].aus;

				 }while((Mat[i].as+Mat[i].ein-Mat[i].aus)&gt;=0);
		} 

	for(int i=0;i&lt;n;i++) 
		{ 
			cout&lt;&lt;&quot;Name von Material &quot;&lt;&lt;i+1&lt;&lt;&quot; : &quot;&lt;&lt;Mat[i].name&lt;&lt;endl; 
			cout&lt;&lt;&quot;Anfangsstock: &quot;&lt;&lt;Mat[i].as&lt;&lt;endl; 
			cout&lt;&lt;&quot;Eingang: &quot;&lt;&lt;Mat[i].ein&lt;&lt;endl; 
			cout&lt;&lt;&quot;Ausgang: &quot;&lt;&lt;Mat[i].aus&lt;&lt;endl;

		}

	_getch();
	return 0;

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2477418</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2477418</guid><dc:creator><![CDATA[Kajiarashi]]></dc:creator><pubDate>Sat, 28 Nov 2015 13:46:38 GMT</pubDate></item><item><title><![CDATA[Reply to Probelm bei do while Schleife on Sat, 28 Nov 2015 13:56:42 GMT]]></title><description><![CDATA[<p>Eine do-while Schleife geht solange bis die Bedingung nicht mehr erfüllt ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2477419</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2477419</guid><dc:creator><![CDATA[Techel]]></dc:creator><pubDate>Sat, 28 Nov 2015 13:56:42 GMT</pubDate></item><item><title><![CDATA[Reply to Probelm bei do while Schleife on Sat, 28 Nov 2015 16:03:54 GMT]]></title><description><![CDATA[<p>Danke. Jetzt habe ich es geändert, jedoch wenn ein ERROR nicht nötig ist macht er es trotzdem ein mal. Warum ist das so? Ist mit der Reihenfolge etwas nicht in Ordnung?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2477428</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2477428</guid><dc:creator><![CDATA[Kajiarashi]]></dc:creator><pubDate>Sat, 28 Nov 2015 16:03:54 GMT</pubDate></item><item><title><![CDATA[Reply to Probelm bei do while Schleife on Sat, 28 Nov 2015 16:13:42 GMT]]></title><description><![CDATA[<p>Guck mal wann die Bedingung einer do-while Schleife geprüft wird <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/2477429</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2477429</guid><dc:creator><![CDATA[Techel]]></dc:creator><pubDate>Sat, 28 Nov 2015 16:13:42 GMT</pubDate></item><item><title><![CDATA[Reply to Probelm bei do while Schleife on Sat, 28 Nov 2015 16:21:15 GMT]]></title><description><![CDATA[<p>Ich habs mit einer einfachen While Schleife probiert. Es funktioniert anscheinend. Werde aber noch weiter versuchen.<br />
Danke <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="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2477430</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2477430</guid><dc:creator><![CDATA[Kajiarashi]]></dc:creator><pubDate>Sat, 28 Nov 2015 16:21:15 GMT</pubDate></item><item><title><![CDATA[Reply to Probelm bei do while Schleife on Sat, 28 Nov 2015 16:22:51 GMT]]></title><description><![CDATA[<p>Richtig, du solltest eine while-Schleife benutzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2477431</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2477431</guid><dc:creator><![CDATA[Techel]]></dc:creator><pubDate>Sat, 28 Nov 2015 16:22:51 GMT</pubDate></item></channel></rss>