<?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[Taschenrechner]]></title><description><![CDATA[<p>Hallo !</p>
<p>Wie baue ich eine Schleife ein,welche fragt ob weitere Rechnungen durchgeführt werden sollen ?<br />
Danke !</p>
<p>LG</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
  #include &lt;cmath&gt;   //header für mathe ops

  using namespace std;

  int menu () {  //modul für übersichtlichkeit

      int i;

/*-------------------------------------------------------------------------------*/ 

      // Begrüßung 
      cout &lt;&lt; &quot;\n&quot;
              &quot;\n\tHerzlich Willkommen!&quot;
              &quot;\n&quot;   ;

      system (&quot;Pause&quot;);  //pause

      system (&quot;cls&quot;) ;   //conolsentext löschen

/*-------------------------------------------------------------------------------*/   

    // Funktionen in einem übersichtlichen Menü

cout &lt;&lt; &quot;\n\t&lt;----------Taschenrechner------------&gt;&quot;
        &quot;\n&quot;
        &quot;\n\t[1] Addition&quot;
        &quot;\n\t[2] Subtraktion&quot;
        &quot;\n\t[3] Multiplikation&quot;
        &quot;\n\t[4] Division&quot;
        &quot;\n\t[5] Potenz&quot;
        &quot;\n\t[6] Wurzel&quot;
        &quot;\n\t[7] Programm beenden&quot;
        &quot;\n&quot;
        &quot;\n\t&lt;------------------------------------&gt;&quot;
        &quot;\n&quot;
        &quot;\nBitte waehlen sie eine Funktion und druecken sie enter&quot; 
        &quot;\n&quot;
        &quot;\n&quot;
        &quot;\n&quot;
        &quot;\n&quot; 
        &quot;\n&quot;
        &quot;\n&quot;
        &quot;\n&quot; ;

cin &gt;&gt; i;  //eingabe der auswahl ist oben deklariert worden
return i;  //damit wir i in hauptfunktioen benutzen können

        }
/*-------------------------------------------------------------------------------*/ 

int main () {    //hauptmenü

bool quit=false;                    //variable j/n
int schluss;                        //beenden
long double a, b;                  //variable
int aus=menu();                        //auswahl
do {                            //do schleife damit bestimmte dinge wiederhollt werden
switch (aus) {                        //bedingungsschleife

/*-------------------------------------------------------------------------------*/

    case 1:                    
    case 2:
    case 3:                        
    case 4:

        cout &lt;&lt; &quot;\n\n\tBitte ersten Operanden eingeben : &quot;;
        cin &gt;&gt; a;
        cout &lt;&lt; &quot;\n\n\tBitte zweite Operanden eingeben : &quot;;
        cin &gt;&gt; b;
        switch(aus) {                            //nochmal das selbe nur jetz einzeln

                  case 1: cout &lt;&lt; &quot;\n\t&quot; &lt;&lt; a &lt;&lt; &quot; + &quot; &lt;&lt; b &lt;&lt; &quot; = &quot; &lt;&lt; a + b &lt;&lt; endl; break;          //plus
                  case 2: cout &lt;&lt; &quot;\n\t&quot; &lt;&lt; a &lt;&lt; &quot; - &quot; &lt;&lt; b &lt;&lt; &quot; = &quot; &lt;&lt; a - b &lt;&lt; endl; break;    //minus
                  case 3: cout &lt;&lt; &quot;\n\t&quot; &lt;&lt; a &lt;&lt; &quot; * &quot; &lt;&lt; b &lt;&lt; &quot; = &quot; &lt;&lt; a * b &lt;&lt; endl; break;    //mal
                  case 4: cout &lt;&lt; &quot;\n\t&quot; &lt;&lt; a &lt;&lt; &quot; / &quot; &lt;&lt; b &lt;&lt; &quot; = &quot; &lt;&lt; a / b &lt;&lt; endl; break;    //geteilt
        }
    quit=true;                                //beenden--&gt; wahr
    break;                        //break --&gt; endlich

/*-------------------------------------------------------------------------------*/

    case 5:
    case 6:
        cout &lt;&lt; &quot;\n\n\tBitte Operanden eingeben : &quot;;
        cin &gt;&gt; a;
        switch (aus) {                       

            case 5: cout &lt;&lt; &quot;\n\t&quot; &lt;&lt; a &lt;&lt; &quot; zum Quadrat ist = &quot; &lt;&lt; a*a &lt;&lt; endl; break;    //hochrechnen
                    cout &lt;&lt; &quot;\n&quot;
                            &quot;\n&quot;
                            &quot;\n&quot;;    

            case 6:    cout &lt;&lt; &quot;\n\tDie Wurzel von &quot; &lt;&lt; a &lt;&lt;  &quot;=&quot; &lt;&lt; sqrt(a) &lt;&lt; endl; break; //wurzel dafür cmath
                       cout &lt;&lt; &quot;\n&quot;
                               &quot;\n&quot;
                               &quot;\n&quot;;

        }                   
    quit=true;                    //beenden --&gt; wahr
    break;                        //break --&gt; endlich

/*-------------------------------------------------------------------------------*/    

    case 7:  exit(0) ; //programm beenden

/*-------------------------------------------------------------------------------*/    

   default:
          cout &lt;&lt; &quot;\n\tFalsche eingabe&quot;;            //wenn falsche eingabe
    break;

}                            

}while (!quit);                        //do schleife schliesen mit bedingung das quit nicht wahr sein darf                    

system (&quot;Pause&quot;);
system (&quot;cls&quot;);   

/*-------------------------------------------------------------------------------*/

cout &lt;&lt; &quot;\n&quot;
        &quot;\n&quot;
        &quot;\nIch hoffe sie hatten viel Spass mit diesem kleinen Taschenrechner!&quot;
        &quot;\n&quot;
        &quot;\n&quot;
        &quot;\n&quot;
        &quot;\n&quot;
        &quot;\n\tBitte beliebige Taste und dann enter druecken zum beenden&quot;;
cin &gt;&gt; schluss;

return 0;

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/241493/taschenrechner</link><generator>RSS for Node</generator><lastBuildDate>Mon, 21 Sep 2026 11:08:07 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/241493.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 21 May 2009 11:33:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Taschenrechner on Thu, 21 May 2009 11:33:21 GMT]]></title><description><![CDATA[<p>Hallo !</p>
<p>Wie baue ich eine Schleife ein,welche fragt ob weitere Rechnungen durchgeführt werden sollen ?<br />
Danke !</p>
<p>LG</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
  #include &lt;cmath&gt;   //header für mathe ops

  using namespace std;

  int menu () {  //modul für übersichtlichkeit

      int i;

/*-------------------------------------------------------------------------------*/ 

      // Begrüßung 
      cout &lt;&lt; &quot;\n&quot;
              &quot;\n\tHerzlich Willkommen!&quot;
              &quot;\n&quot;   ;

      system (&quot;Pause&quot;);  //pause

      system (&quot;cls&quot;) ;   //conolsentext löschen

/*-------------------------------------------------------------------------------*/   

    // Funktionen in einem übersichtlichen Menü

cout &lt;&lt; &quot;\n\t&lt;----------Taschenrechner------------&gt;&quot;
        &quot;\n&quot;
        &quot;\n\t[1] Addition&quot;
        &quot;\n\t[2] Subtraktion&quot;
        &quot;\n\t[3] Multiplikation&quot;
        &quot;\n\t[4] Division&quot;
        &quot;\n\t[5] Potenz&quot;
        &quot;\n\t[6] Wurzel&quot;
        &quot;\n\t[7] Programm beenden&quot;
        &quot;\n&quot;
        &quot;\n\t&lt;------------------------------------&gt;&quot;
        &quot;\n&quot;
        &quot;\nBitte waehlen sie eine Funktion und druecken sie enter&quot; 
        &quot;\n&quot;
        &quot;\n&quot;
        &quot;\n&quot;
        &quot;\n&quot; 
        &quot;\n&quot;
        &quot;\n&quot;
        &quot;\n&quot; ;

cin &gt;&gt; i;  //eingabe der auswahl ist oben deklariert worden
return i;  //damit wir i in hauptfunktioen benutzen können

        }
/*-------------------------------------------------------------------------------*/ 

int main () {    //hauptmenü

bool quit=false;                    //variable j/n
int schluss;                        //beenden
long double a, b;                  //variable
int aus=menu();                        //auswahl
do {                            //do schleife damit bestimmte dinge wiederhollt werden
switch (aus) {                        //bedingungsschleife

/*-------------------------------------------------------------------------------*/

    case 1:                    
    case 2:
    case 3:                        
    case 4:

        cout &lt;&lt; &quot;\n\n\tBitte ersten Operanden eingeben : &quot;;
        cin &gt;&gt; a;
        cout &lt;&lt; &quot;\n\n\tBitte zweite Operanden eingeben : &quot;;
        cin &gt;&gt; b;
        switch(aus) {                            //nochmal das selbe nur jetz einzeln

                  case 1: cout &lt;&lt; &quot;\n\t&quot; &lt;&lt; a &lt;&lt; &quot; + &quot; &lt;&lt; b &lt;&lt; &quot; = &quot; &lt;&lt; a + b &lt;&lt; endl; break;          //plus
                  case 2: cout &lt;&lt; &quot;\n\t&quot; &lt;&lt; a &lt;&lt; &quot; - &quot; &lt;&lt; b &lt;&lt; &quot; = &quot; &lt;&lt; a - b &lt;&lt; endl; break;    //minus
                  case 3: cout &lt;&lt; &quot;\n\t&quot; &lt;&lt; a &lt;&lt; &quot; * &quot; &lt;&lt; b &lt;&lt; &quot; = &quot; &lt;&lt; a * b &lt;&lt; endl; break;    //mal
                  case 4: cout &lt;&lt; &quot;\n\t&quot; &lt;&lt; a &lt;&lt; &quot; / &quot; &lt;&lt; b &lt;&lt; &quot; = &quot; &lt;&lt; a / b &lt;&lt; endl; break;    //geteilt
        }
    quit=true;                                //beenden--&gt; wahr
    break;                        //break --&gt; endlich

/*-------------------------------------------------------------------------------*/

    case 5:
    case 6:
        cout &lt;&lt; &quot;\n\n\tBitte Operanden eingeben : &quot;;
        cin &gt;&gt; a;
        switch (aus) {                       

            case 5: cout &lt;&lt; &quot;\n\t&quot; &lt;&lt; a &lt;&lt; &quot; zum Quadrat ist = &quot; &lt;&lt; a*a &lt;&lt; endl; break;    //hochrechnen
                    cout &lt;&lt; &quot;\n&quot;
                            &quot;\n&quot;
                            &quot;\n&quot;;    

            case 6:    cout &lt;&lt; &quot;\n\tDie Wurzel von &quot; &lt;&lt; a &lt;&lt;  &quot;=&quot; &lt;&lt; sqrt(a) &lt;&lt; endl; break; //wurzel dafür cmath
                       cout &lt;&lt; &quot;\n&quot;
                               &quot;\n&quot;
                               &quot;\n&quot;;

        }                   
    quit=true;                    //beenden --&gt; wahr
    break;                        //break --&gt; endlich

/*-------------------------------------------------------------------------------*/    

    case 7:  exit(0) ; //programm beenden

/*-------------------------------------------------------------------------------*/    

   default:
          cout &lt;&lt; &quot;\n\tFalsche eingabe&quot;;            //wenn falsche eingabe
    break;

}                            

}while (!quit);                        //do schleife schliesen mit bedingung das quit nicht wahr sein darf                    

system (&quot;Pause&quot;);
system (&quot;cls&quot;);   

/*-------------------------------------------------------------------------------*/

cout &lt;&lt; &quot;\n&quot;
        &quot;\n&quot;
        &quot;\nIch hoffe sie hatten viel Spass mit diesem kleinen Taschenrechner!&quot;
        &quot;\n&quot;
        &quot;\n&quot;
        &quot;\n&quot;
        &quot;\n&quot;
        &quot;\n\tBitte beliebige Taste und dann enter druecken zum beenden&quot;;
cin &gt;&gt; schluss;

return 0;

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1713679</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1713679</guid><dc:creator><![CDATA[nepu]]></dc:creator><pubDate>Thu, 21 May 2009 11:33:21 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner on Thu, 21 May 2009 13:02:47 GMT]]></title><description><![CDATA[<p>Überleg dir doch mal ob du system(&quot;Pause&quot;) und system(&quot;cls&quot;) nicht ändern willst.<br />
Das ist dermaßen hässlich <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/1713715</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1713715</guid><dc:creator><![CDATA[Meinungsvertreter]]></dc:creator><pubDate>Thu, 21 May 2009 13:02:47 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner on Thu, 21 May 2009 13:09:47 GMT]]></title><description><![CDATA[<p>Meinungsvertreter schrieb:</p>
<blockquote>
<p>Überleg dir doch mal ob du system(&quot;Pause&quot;) und system(&quot;cls&quot;) nicht ändern willst.<br />
Das ist dermaßen hässlich <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>
</blockquote>
<p>Das mag sein. Aber wie baut er eine Schleife ein,welche fragt ob weitere Rechnungen durchgeführt werden sollen? Welchen Befehl soll er statt system(&quot;cls&quot;); nehmen? Welchen Befehl soll er statt system(&quot;pause&quot;); nehmen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1713717</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1713717</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 21 May 2009 13:09:47 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner on Thu, 21 May 2009 13:13:44 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>Meinungsvertreter schrieb:</p>
<blockquote>
<p>Überleg dir doch mal ob du system(&quot;Pause&quot;) und system(&quot;cls&quot;) nicht ändern willst.<br />
Das ist dermaßen hässlich <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>
</blockquote>
<p>Das mag sein. Aber wie baut er eine Schleife ein,welche fragt ob weitere Rechnungen durchgeführt werden sollen? Welchen Befehl soll er statt system(&quot;cls&quot;); nehmen? Welchen Befehl soll er statt system(&quot;pause&quot;); nehmen?</p>
</blockquote>
<p>Wozu die beiden Befehle? Unter Linux gibts das nicht und ich kann mir nicht vorstellen wozu das gut wäre. Und um das ganze ding de while schleife zu packen bin ich zu faul, da er so merkwürdige Kommentar linien gemacht hat. <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>Für pause gibts sleep(unsigned int seconds) und dieses komische cls ist wohl windoof only <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1713720</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1713720</guid><dc:creator><![CDATA[Meinungsvertreter]]></dc:creator><pubDate>Thu, 21 May 2009 13:13:44 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner on Thu, 21 May 2009 13:31:00 GMT]]></title><description><![CDATA[<p>Meinungsvertreter schrieb:</p>
<blockquote>
<p>Wozu die beiden Befehle?</p>
</blockquote>
<p>zum bildschirmlöschen und auf-tastendruck-warten.</p>
<blockquote>
<p>Unter Linux gibts das nicht</p>
</blockquote>
<p>klar. system(&quot;clear&quot;) und system(&quot;read&quot;). was bist denn du für ein linuxer?</p>
<blockquote>
<p>und ich kann mir nicht vorstellen wozu das gut wäre.</p>
</blockquote>
<p>das ist auch nicht deine aufgabe. es reicht, wenn nepu sich das vorstellen kann.</p>
<blockquote>
<p>Und um das ganze ding de while schleife zu packen bin ich zu faul, da er so merkwürdige Kommentar linien gemacht hat. <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>
</blockquote>
<p>das läßt sich beheben:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;cmath&gt;   //header für mathe ops

using namespace std;

int menu ()    //modul für übersichtlichkeit
{

    int i;

    // Begrüßung
    cout &lt;&lt; &quot;\n&quot;
         &quot;\n\tHerzlich Willkommen!&quot;
         &quot;\n&quot;   ;

    system (&quot;Pause&quot;);  //pause

    system (&quot;cls&quot;) ;   //conolsentext löschen

    // Funktionen in einem übersichtlichen Menü

    cout &lt;&lt; &quot;\n\t&lt;----------Taschenrechner------------&gt;&quot;
         &quot;\n&quot;
         &quot;\n\t[1] Addition&quot;
         &quot;\n\t[2] Subtraktion&quot;
         &quot;\n\t[3] Multiplikation&quot;
         &quot;\n\t[4] Division&quot;
         &quot;\n\t[5] Potenz&quot;
         &quot;\n\t[6] Wurzel&quot;
         &quot;\n\t[7] Programm beenden&quot;
         &quot;\n&quot;
         &quot;\n\t&lt;------------------------------------&gt;&quot;
         &quot;\n&quot;
         &quot;\nBitte waehlen sie eine Funktion und druecken sie enter&quot;
         &quot;\n&quot;
         &quot;\n&quot;
         &quot;\n&quot;
         &quot;\n&quot;
         &quot;\n&quot;
         &quot;\n&quot;
         &quot;\n&quot; ;

    cin &gt;&gt; i;  //eingabe der auswahl ist oben deklariert worden
    return i;  //damit wir i in hauptfunktioen benutzen können

}

int main ()      //hauptmenü
{

    bool quit=false;                    //variable j/n
    int schluss;                        //beenden
    long double a, b;                  //variable
    int aus=menu();                        //auswahl
    do                              //do schleife damit bestimmte dinge wiederhollt werden
    {
        switch (aus)                          //bedingungsschleife
        {

        case 1:
        case 2:
        case 3:
        case 4:

            cout &lt;&lt; &quot;\n\n\tBitte ersten Operanden eingeben : &quot;;
            cin &gt;&gt; a;
            cout &lt;&lt; &quot;\n\n\tBitte zweite Operanden eingeben : &quot;;
            cin &gt;&gt; b;
            switch (aus)                             //nochmal das selbe nur jetz einzeln
            {

            case 1:
                cout &lt;&lt; &quot;\n\t&quot; &lt;&lt; a &lt;&lt; &quot; + &quot; &lt;&lt; b &lt;&lt; &quot; = &quot; &lt;&lt; a + b &lt;&lt; endl;
                break;          //plus
            case 2:
                cout &lt;&lt; &quot;\n\t&quot; &lt;&lt; a &lt;&lt; &quot; - &quot; &lt;&lt; b &lt;&lt; &quot; = &quot; &lt;&lt; a - b &lt;&lt; endl;
                break;    //minus
            case 3:
                cout &lt;&lt; &quot;\n\t&quot; &lt;&lt; a &lt;&lt; &quot; * &quot; &lt;&lt; b &lt;&lt; &quot; = &quot; &lt;&lt; a * b &lt;&lt; endl;
                break;    //mal
            case 4:
                cout &lt;&lt; &quot;\n\t&quot; &lt;&lt; a &lt;&lt; &quot; / &quot; &lt;&lt; b &lt;&lt; &quot; = &quot; &lt;&lt; a / b &lt;&lt; endl;
                break;    //geteilt
            }
            quit=true;                                //beenden--&gt; wahr
            break;                        //break --&gt; endlich

        case 5:
        case 6:
            cout &lt;&lt; &quot;\n\n\tBitte Operanden eingeben : &quot;;
            cin &gt;&gt; a;
            switch (aus)
            {

            case 5:
                cout &lt;&lt; &quot;\n\t&quot; &lt;&lt; a &lt;&lt; &quot; zum Quadrat ist = &quot; &lt;&lt; a*a &lt;&lt; endl;
                break;    //hochrechnen
                cout &lt;&lt; &quot;\n&quot;
                     &quot;\n&quot;
                     &quot;\n&quot;;

            case 6:
                cout &lt;&lt; &quot;\n\tDie Wurzel von &quot; &lt;&lt; a &lt;&lt;  &quot;=&quot; &lt;&lt; sqrt(a) &lt;&lt; endl;
                break; //wurzel dafür cmath
                cout &lt;&lt; &quot;\n&quot;
                     &quot;\n&quot;
                     &quot;\n&quot;;

            }
            quit=true;                    //beenden --&gt; wahr
            break;                        //break --&gt; endlich

        case 7:
            exit(0) ; //programm beenden

            /*-------------------------------------------------------------------------------*/

        default:
            cout &lt;&lt; &quot;\n\tFalsche eingabe&quot;;            //wenn falsche eingabe
            break;

        }

    }
    while (!quit);                        //do schleife schliesen mit bedingung das quit nicht wahr sein darf

    system (&quot;Pause&quot;);
    system (&quot;cls&quot;);

    cout &lt;&lt; &quot;\n&quot;
         &quot;\n&quot;
         &quot;\nIch hoffe sie hatten viel Spass mit diesem kleinen Taschenrechner!&quot;
         &quot;\n&quot;
         &quot;\n&quot;
         &quot;\n&quot;
         &quot;\n&quot;
         &quot;\n\tBitte beliebige Taste und dann enter druecken zum beenden&quot;;
    cin &gt;&gt; schluss;

    return 0;

}
</code></pre>
<blockquote>
<p>Für pause gibts sleep(unsigned int seconds) und dieses komische cls ist wohl windows only <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
</blockquote>
<p>pause wartet auf einen tastendruck. es reicht, stattdessen auf enter zu warten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1713734</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1713734</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 21 May 2009 13:31:00 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner on Thu, 21 May 2009 13:44:11 GMT]]></title><description><![CDATA[<p>nepu schrieb:</p>
<blockquote>
<p>Wie baue ich eine Schleife ein,welche fragt ob weitere Rechnungen durchgeführt werden sollen ?</p>
</blockquote>
<p>eigentlich hast du diese schleife schon. setzt halt nur dann quit=true, wenn der benutzer wirklich beenden will.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#include &lt;cmath&gt;   //header für mathe ops

using namespace std;

int menu ()    //modul für übersichtlichkeit
{

    int i;

    // Begrüßung
    cout &lt;&lt; &quot;\n&quot;
         &quot;\n\tHerzlich Willkommen!&quot;
         &quot;\n&quot;   ;

    system (&quot;Pause&quot;);  //pause

    system (&quot;cls&quot;) ;   //conolsentext löschen

    // Funktionen in einem übersichtlichen Menü

    cout &lt;&lt; &quot;\n\t&lt;----------Taschenrechner------------&gt;&quot;
         &quot;\n&quot;
         &quot;\n\t[1] Addition&quot;
         &quot;\n\t[2] Subtraktion&quot;
         &quot;\n\t[3] Multiplikation&quot;
         &quot;\n\t[4] Division&quot;
         &quot;\n\t[5] Potenz&quot;
         &quot;\n\t[6] Wurzel&quot;
         &quot;\n\t[7] Programm beenden&quot;
         &quot;\n&quot;
         &quot;\n\t&lt;------------------------------------&gt;&quot;
         &quot;\n&quot;
         &quot;\nBitte waehlen sie eine Funktion und druecken sie enter&quot;
         &quot;\n&quot;
         &quot;\n&quot;
         &quot;\n&quot;
         &quot;\n&quot;
         &quot;\n&quot;
         &quot;\n&quot;
         &quot;\n&quot; ;

    cin &gt;&gt; i;  //eingabe der auswahl ist oben deklariert worden
    return i;  //damit wir i in hauptfunktioen benutzen können

}

int main ()      //hauptmenü
{

    bool quit=false;                    //variable j/n
    long double a, b;                  //variable
    do                              //do schleife damit bestimmte dinge wiederhollt werden
    {
		int aus=menu();                        //auswahl
        switch (aus)                          //bedingungsschleife
        {

        case 1:
        case 2:
        case 3:
        case 4:

            cout &lt;&lt; &quot;\n\n\tBitte ersten Operanden eingeben : &quot;;
            cin &gt;&gt; a;
            cout &lt;&lt; &quot;\n\n\tBitte zweite Operanden eingeben : &quot;;
            cin &gt;&gt; b;
            switch (aus)                             //nochmal das selbe nur jetz einzeln
            {

            case 1:
                cout &lt;&lt; &quot;\n\t&quot; &lt;&lt; a &lt;&lt; &quot; + &quot; &lt;&lt; b &lt;&lt; &quot; = &quot; &lt;&lt; a + b &lt;&lt; endl;
                break;          //plus
            case 2:
                cout &lt;&lt; &quot;\n\t&quot; &lt;&lt; a &lt;&lt; &quot; - &quot; &lt;&lt; b &lt;&lt; &quot; = &quot; &lt;&lt; a - b &lt;&lt; endl;
                break;    //minus
            case 3:
                cout &lt;&lt; &quot;\n\t&quot; &lt;&lt; a &lt;&lt; &quot; * &quot; &lt;&lt; b &lt;&lt; &quot; = &quot; &lt;&lt; a * b &lt;&lt; endl;
                break;    //mal
            case 4:
                cout &lt;&lt; &quot;\n\t&quot; &lt;&lt; a &lt;&lt; &quot; / &quot; &lt;&lt; b &lt;&lt; &quot; = &quot; &lt;&lt; a / b &lt;&lt; endl;
                break;    //geteilt
            }
            break;                        //break --&gt; endlich

        case 5:
        case 6:
            cout &lt;&lt; &quot;\n\n\tBitte Operanden eingeben : &quot;;
            cin &gt;&gt; a;
            switch (aus)
            {

            case 5:
                cout &lt;&lt; &quot;\n\t&quot; &lt;&lt; a &lt;&lt; &quot; zum Quadrat ist = &quot; &lt;&lt; a*a &lt;&lt; endl;
                break;    //hochrechnen
                cout &lt;&lt; &quot;\n&quot;
                     &quot;\n&quot;
                     &quot;\n&quot;;

            case 6:
                cout &lt;&lt; &quot;\n\tDie Wurzel von &quot; &lt;&lt; a &lt;&lt;  &quot;=&quot; &lt;&lt; sqrt(a) &lt;&lt; endl;
                break; //wurzel dafür cmath
                cout &lt;&lt; &quot;\n&quot;
                     &quot;\n&quot;
                     &quot;\n&quot;;

            }
            break;

        case 7:
            quit=true;                    //beenden --&gt; wahr
            break;

            /*-------------------------------------------------------------------------------*/

        default:
            cout &lt;&lt; &quot;\n\tFalsche eingabe&quot;;            //wenn falsche eingabe
            break;

        }

    }
    while (!quit);                        //do schleife schliesen mit bedingung das quit nicht wahr sein darf

    system (&quot;Pause&quot;);
    system (&quot;cls&quot;);

    cout &lt;&lt; &quot;\n&quot;
         &quot;\n&quot;
         &quot;\nIch hoffe sie hatten viel Spass mit diesem kleinen Taschenrechner!&quot;
         &quot;\n&quot;
         &quot;\n&quot;
         &quot;\n&quot;
         &quot;\n&quot;
         &quot;\n\tBitte beliebige Taste und dann enter druecken zum beenden&quot;;
    system (&quot;Pause&quot;);

    return 0;

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1713737</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1713737</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 21 May 2009 13:44:11 GMT</pubDate></item></channel></rss>