<?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[Ja Nein Abfrage]]></title><description><![CDATA[<p>Hi, ich schreibe morgen eine Arbeit in Ami und war deswegen jetzt dafür am lernen. Eine Aufgabe besteht darin, ein Programm zu machen (egal welches) bei dem am Ende abgefragt wird ob man nochmal will j/n, bei j soll es nochmal von vorne beginnen (danach natürlich wieder die Abfrage), bei n soll es das Programm beenden und bei irgend einer anderen Eingabe soll es z.B. sagen &quot;Falsche Eingabe&quot; und dann nochmal die &quot;Nochmal&quot;-Abfrage machen. Eigentlich würde ich das schaffen, aber es soll keine Spaghetti-Programmierung sein, also so unübersichtlich. Ich weiß einfach nicht wie ich das machen soll. Würde mich echt freuen wenn mir jemand helfen könnte! Hier ist das Programm soweit:</p>
<pre><code class="language-cpp">#include &lt;iostream.h&gt;
#include &lt;conio.h&gt;

int main()
{
 float z1, z2, erg;
 char z3;
 do
 {

        cout&lt;&lt;&quot;Division\n&quot;;
        cout&lt;&lt;&quot;Zähler 1:&quot;;
        cin&gt;&gt;z1;
        cout&lt;&lt;&quot;Nenner 2:&quot;;
        cin&gt;&gt;z2;
        erg=z1/z2;
        cout&lt;&lt;&quot;Ergebnis:&quot;&lt;&lt;erg;
        getch();
        cout&lt;&lt;&quot;\nNochmal? j/n\n&quot;;
        cin&gt;&gt;z3;
        }
        while (z3=='j');
        {

                if (z3=='n')

                {       cout&lt;&lt;&quot;Ende&quot;;
                        getch();
                }

                else
                        {
                        cout&lt;&lt;&quot;Falsche Eingabe!&quot;;
                        getch();
                        }

           }

       return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/128861/ja-nein-abfrage</link><generator>RSS for Node</generator><lastBuildDate>Tue, 25 Aug 2026 22:05:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/128861.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 07 Dec 2005 20:29:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ja Nein Abfrage on Wed, 07 Dec 2005 20:29:53 GMT]]></title><description><![CDATA[<p>Hi, ich schreibe morgen eine Arbeit in Ami und war deswegen jetzt dafür am lernen. Eine Aufgabe besteht darin, ein Programm zu machen (egal welches) bei dem am Ende abgefragt wird ob man nochmal will j/n, bei j soll es nochmal von vorne beginnen (danach natürlich wieder die Abfrage), bei n soll es das Programm beenden und bei irgend einer anderen Eingabe soll es z.B. sagen &quot;Falsche Eingabe&quot; und dann nochmal die &quot;Nochmal&quot;-Abfrage machen. Eigentlich würde ich das schaffen, aber es soll keine Spaghetti-Programmierung sein, also so unübersichtlich. Ich weiß einfach nicht wie ich das machen soll. Würde mich echt freuen wenn mir jemand helfen könnte! Hier ist das Programm soweit:</p>
<pre><code class="language-cpp">#include &lt;iostream.h&gt;
#include &lt;conio.h&gt;

int main()
{
 float z1, z2, erg;
 char z3;
 do
 {

        cout&lt;&lt;&quot;Division\n&quot;;
        cout&lt;&lt;&quot;Zähler 1:&quot;;
        cin&gt;&gt;z1;
        cout&lt;&lt;&quot;Nenner 2:&quot;;
        cin&gt;&gt;z2;
        erg=z1/z2;
        cout&lt;&lt;&quot;Ergebnis:&quot;&lt;&lt;erg;
        getch();
        cout&lt;&lt;&quot;\nNochmal? j/n\n&quot;;
        cin&gt;&gt;z3;
        }
        while (z3=='j');
        {

                if (z3=='n')

                {       cout&lt;&lt;&quot;Ende&quot;;
                        getch();
                }

                else
                        {
                        cout&lt;&lt;&quot;Falsche Eingabe!&quot;;
                        getch();
                        }

           }

       return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/936848</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/936848</guid><dc:creator><![CDATA[SolidSnkae]]></dc:creator><pubDate>Wed, 07 Dec 2005 20:29:53 GMT</pubDate></item><item><title><![CDATA[Reply to Ja Nein Abfrage on Wed, 07 Dec 2005 20:37:20 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream.h&gt;
#include &lt;conio.h&gt;

int main()
{
 float z1, z2, erg;
 char z3;

 cout&lt;&lt;&quot;Division\n&quot;;
 cout&lt;&lt;&quot;Zähler 1:&quot;;

 cin&gt;&gt;z1;

 cout&lt;&lt;&quot;Nenner 2:&quot;;

 cin&gt;&gt;z2;

 erg=z1/z2;

 cout&lt;&lt;&quot;Ergebnis:&quot;&lt;&lt;erg;

 getch();

 Nochmal: cout&lt;&lt;&quot;\nNochmal? j/n\n&quot;;

 cin&gt;&gt;z3;

 if (z3=='j');
 {

 else if (z3=='n')

 {       
    cout&lt;&lt;&quot;Ende&quot;;
    getch();
 }

 else
 {
    cout&lt;&lt;&quot;Falsche Eingabe!&quot;;
    getch();
    goto Nochmal;
 }

   return 0;
}
</code></pre>
<p>So müsste es gehen...</p>
<p>MfG Riddick04</p>
]]></description><link>https://www.c-plusplus.net/forum/post/936855</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/936855</guid><dc:creator><![CDATA[Riddick04]]></dc:creator><pubDate>Wed, 07 Dec 2005 20:37:20 GMT</pubDate></item><item><title><![CDATA[Reply to Ja Nein Abfrage on Wed, 07 Dec 2005 20:44:40 GMT]]></title><description><![CDATA[<p>erstens ist das hier ein klassisches Beispiel goto nicht zu benutzten.<br />
zwitens solltest du standard header ohne .h inkludieren.<br />
3tens ist zwar do while hier der klassische ansatz und auch keineswegs verkehrt,<br />
aber wie findest du diese möglichkeit ( da es dir ja um aussehen zu gehen scheint)</p>
<p>// bitte beachten ist nicht getestet</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;conio.h&gt;

using namespace std;

int main()
{
	float z1, z2, erg;
 	char z3;

	for(;;){
		cout&lt;&lt;&quot;Division\n&quot;;
    	cout&lt;&lt;&quot;Zähler 1:&quot;;
    	cin&gt;&gt;z1;
    	cout&lt;&lt;&quot;Nenner 2:&quot;;
    	cin&gt;&gt;z2;
	    erg=z1/z2;
    	cout&lt;&lt;&quot;Ergebnis:&quot;&lt;&lt;erg;
    	getch();
    	cout&lt;&lt;&quot;\nNochmal? j/n\n&quot;;

    	cin&gt;&gt;z3;
		if(z3=='n'){
			cout&lt;&lt;&quot;Ende&quot;;
			break;
		}else if(z3=='j'){
			cout&lt;&lt;&quot;dann gehts weiter\n&quot;;//ggf nen continue;
		}else
			cout&lt;&lt;&quot;falsche eingabe(dennoch weiter)\n&quot;;//s.o
	}
       return 0;
}
</code></pre>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/11376">@Riddick04</a>: ohne mir das genau angeguggt zu haben ist es meine bescheidene Meinung das dein code irgendwie eklig ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/936858</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/936858</guid><dc:creator><![CDATA[shapeless]]></dc:creator><pubDate>Wed, 07 Dec 2005 20:44:40 GMT</pubDate></item><item><title><![CDATA[Reply to Ja Nein Abfrage on Wed, 07 Dec 2005 20:53:25 GMT]]></title><description><![CDATA[<p>Okay, soweit klappts dann. Aber was bedeutet das (;;) bei for? Und wie mache ich das, dass er bei einer Falschen Eingabe nicht wieder von vorne anfängt sondern nochmal &quot;Nochmal?&quot; fragt? Aber danke auf jeden Fall!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/936866</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/936866</guid><dc:creator><![CDATA[SolidSnake]]></dc:creator><pubDate>Wed, 07 Dec 2005 20:53:25 GMT</pubDate></item><item><title><![CDATA[Reply to Ja Nein Abfrage on Wed, 07 Dec 2005 21:03:38 GMT]]></title><description><![CDATA[<p>Ich meine natürlich das</p>
<pre><code class="language-cpp">(;;)
</code></pre>
<p>bei for. Blöder Smiley.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/936877</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/936877</guid><dc:creator><![CDATA[SolidSnake]]></dc:creator><pubDate>Wed, 07 Dec 2005 21:03:38 GMT</pubDate></item><item><title><![CDATA[Reply to Ja Nein Abfrage on Wed, 07 Dec 2005 21:28:01 GMT]]></title><description><![CDATA[<p>die for schleife ist grob gesagt wie folgt definiert<br />
for(startwert;!abbruchbedingung;zählintervall)<br />
da wir aber eine endlosschleife wollen brauchen wir keine bedingungen o.Ä. also reicht for(;;)..</p>
<p>und wenn du die abfrage nochmal stellen willst müssen wir diese von der berechnung trennen . in diesem fall ( es geht vll auch eleganter ) geht natürlich eine 2te schleife, die quasi die abfrage durchläuft bis ja oder nein eingegeben wurde.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;conio.h&gt;

using namespace std;

int main()
{
	float z1, z2, erg;
 	char z3;

	for(;;){
		cout&lt;&lt;&quot;Division\n&quot;;
    	cout&lt;&lt;&quot;Zähler 1:&quot;;
    	cin&gt;&gt;z1;
    	cout&lt;&lt;&quot;Nenner 2:&quot;;
    	cin&gt;&gt;z2;
	    erg=z1/z2;
    	cout&lt;&lt;&quot;Ergebnis:&quot;&lt;&lt;erg;
    	getch();
		for(;;){//schleife für unsere frage
    		cout&lt;&lt;&quot;\nNochmal? j/n\n&quot;;
    		cin&gt;&gt;z3;
			if(z3=='n'){
				cout&lt;&lt;&quot;Ende\n&quot;;
				return 0;//ganzes programm wird beendet
			}else if(z3=='j'){
				cout&lt;&lt;&quot;dann gehts weiter\n&quot;;// nur die schleife
				break;//wird beendet und die andere läuft
			}else         // mit der berechnung weiter
				cout&lt;&lt;&quot;falsche eingabe(dennoch weiter)\n&quot;;
				//weiter in der abfragenschleife
		}
	}
       return 0;
}
</code></pre>
<p>//edit smilies</p>
]]></description><link>https://www.c-plusplus.net/forum/post/936896</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/936896</guid><dc:creator><![CDATA[shapeless]]></dc:creator><pubDate>Wed, 07 Dec 2005 21:28:01 GMT</pubDate></item><item><title><![CDATA[Reply to Ja Nein Abfrage on Thu, 08 Dec 2005 08:36:22 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">/////////////////////////////////////
// INCLUDES
/////////////////////////////////////
#include &lt;iostream.h&gt;
#include &lt;conio.h&gt;

////////////////////////////////////
// Hauptfunktion
////////////////////////////////////

int main()
{
   // Deklarationen
   float z1, z2, erg;
   char z3;

   while(true)
   {
      cout &lt;&lt; &quot;Division&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;Zähler 1:&quot;;
      cin&gt;&gt;z1; // Eingabe
      cout &lt;&lt; endl &lt;&lt; &quot;Nenner 2:&quot;;
      cin&gt;&gt;z2; // Eingabe
      erg = z1 / z2; // Berechne
      cout &lt;&lt; &quot;Ergebnis:&quot; &lt;&lt; erg &lt;&lt; endl;;
      getch();
      cout&lt;&lt;&quot;\nNochmal? j/n&quot; &lt;&lt; endl;
      cin&gt;&gt;z3;

      if (z3 == 'n')
      {
         cout &lt;&lt; &quot;Ende&quot;;
         getch();
         break;
      }
      else if (z3 != j)
      {
         cout &lt;&lt; &quot;Falsche Eingabe!&quot; &lt;&lt; endl;
      }
   }

   return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/937056</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/937056</guid><dc:creator><![CDATA[Riddick04]]></dc:creator><pubDate>Thu, 08 Dec 2005 08:36:22 GMT</pubDate></item><item><title><![CDATA[Reply to Ja Nein Abfrage on Thu, 08 Dec 2005 09:02:32 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

int main()
{
	int zaehler, nenner;
	char nochmal = 'j';

	while( nochmal == 'j' )
	{
		cout &lt;&lt; &quot;Division\n&quot;;
		cout &lt;&lt; &quot;Z\x84hler:&quot;;
		cin &gt;&gt; zaehler;
		cout &lt;&lt; &quot;Nenner:&quot;;
		cin &gt;&gt; nenner;
		cout &lt;&lt; &quot;Ergebnis:&quot; &lt;&lt; (zaehler/(float)nenner);

		cout &lt;&lt; &quot;\nNochmal? j/n\n&quot;;
		cin &gt;&gt; nochmal;

		while( nochmal!='j' &amp;&amp; nochmal!='n' )
		{
			cout &lt;&lt; &quot;FALSCHE EINGABE!!!\nNochmal? j/n\n&quot;;
			cin &gt;&gt; nochmal;
		}
	}

	cout &lt;&lt; &quot;Auf Wiedersehen!&quot; &lt;&lt; endl;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/937068</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/937068</guid><dc:creator><![CDATA[schorsch code]]></dc:creator><pubDate>Thu, 08 Dec 2005 09:02:32 GMT</pubDate></item><item><title><![CDATA[Reply to Ja Nein Abfrage on Thu, 08 Dec 2005 09:20:48 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/11376">@Riddick04</a>: Benutz mal die neuen Header, die mit .h sind veraltet:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

using namespace std;

int main(int argc, char **argv) {
  float n,z,erg;
  char c;

  do {
    cout&lt;&lt;&quot;\nZahler: &quot;;
    cin&gt;&gt;z;

    cout&lt;&lt;&quot;\nNenner: &quot;;
    cin&gt;&gt;n;

    if (n==0)
      break;

    erg = z/n;
    cout&lt;&lt;&quot;\nErgebnis: &quot;&lt;&lt;erg;

    cout&lt;&lt;&quot;Nochmal (j/n) ?&quot;;
    cin&gt;&gt;c;
  }while(c!='n');

  return EXIT_SUCCESS;
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/937082</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/937082</guid><dc:creator><![CDATA[GPC]]></dc:creator><pubDate>Thu, 08 Dec 2005 09:20:48 GMT</pubDate></item></channel></rss>