<?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[C++ Taschenrechner]]></title><description><![CDATA[<p>Hallo</p>
<p>wir machen in der schule c++ im programm Dev-C++<br />
wir programmieren jetzt einen taschenrechner das an sich auch kein großes problem ist aber jetzt soll die ganze eingabe in einer zeile erfolgen...<br />
also soll man schreiben : 5 + 5 = 10<br />
und das in einer zeile....</p>
<p>das bekomme ich leider nicht hin .... könnte mir jemand den folgenden code so umschreiben das es funktioniert??</p>
<p>schonmal danke im vorraus</p>
<p>lohminio</p>
<p>code</p>
<p>#include &lt;iostream&gt;<br />
#include &lt;math.h&gt;</p>
<p>using namespace std;</p>
<p>float Addieren (float a, float b);<br />
float Subtrahieren (float a, float b);<br />
float Multiplizieren (float a, float b);<br />
float Dividieren (float a, float b);<br />
float Wurzel (float a, float b);<br />
float Potenzieren (float a, float b);</p>
<p>main() {<br />
// Dekla<br />
start:<br />
float a,b,c;<br />
int Rechenart ;</p>
<p>// Menü<br />
cout &lt;&lt; &quot;Taschenrechner\n&quot; &lt;&lt; endl;<br />
cout &lt;&lt; &quot;Waehlen Sie die Rechenart:\n&quot; &lt;&lt; endl;</p>
<p>cout &lt;&lt; &quot;[1] Addieren&quot; &lt;&lt; endl;</p>
<p>cout &lt;&lt; &quot;[2] Subtrahieren&quot; &lt;&lt; endl;</p>
<p>cout &lt;&lt; &quot;[3] Multiplizieren&quot; &lt;&lt; endl;</p>
<p>cout &lt;&lt; &quot;[4] Dividieren&quot; &lt;&lt; endl;</p>
<p>cout &lt;&lt; &quot;[5] Wurzel&quot; &lt;&lt; endl;</p>
<p>cout &lt;&lt; &quot;[6] Potenzieren&quot; &lt;&lt; endl;</p>
<p>cout &lt;&lt; &quot;Rechenart??&quot; &lt;&lt; endl;<br />
cin &gt;&gt; Rechenart;</p>
<p>//zahlen eingeben<br />
cout &lt;&lt; &quot;Zahl a eingeben: &quot;;<br />
cin &gt;&gt; a;<br />
cout &lt;&lt; &quot;Zahl b eingeben: &quot;;<br />
cin &gt;&gt; b;</p>
<p>//berechnen<br />
if (Rechenart == 1)<br />
{<br />
c = Addieren(a,b);<br />
cout &lt;&lt; &quot;Ergebnis = &quot; &lt;&lt; c;<br />
}</p>
<p>if (Rechenart == 2)<br />
{<br />
c = Subtrahieren (a,b);<br />
cout &lt;&lt; &quot;Ergebnis = &quot;&lt;&lt; c;<br />
}</p>
<p>if (Rechenart == 3)<br />
{<br />
c = Multiplizieren (a,b);<br />
cout &lt;&lt; &quot;Ergebnis = &quot;&lt;&lt; c;<br />
}</p>
<p>if (Rechenart == 4)<br />
{<br />
c = Dividieren (a,b);<br />
cout &lt;&lt; &quot;Ergebnis = &quot; &lt;&lt; c;<br />
}</p>
<p>if (Rechenart == 5)<br />
{<br />
c = Wurzel (a,b);<br />
cout &lt;&lt; &quot;Ergebnis = &quot; &lt;&lt; c;<br />
}</p>
<p>if (Rechenart == 6)<br />
{<br />
c = Potenzieren(a,b);<br />
cout &lt;&lt; &quot;Ergenis = &quot; &lt;&lt; c;<br />
}</p>
<p>string ende;<br />
cin &gt;&gt; ende;</p>
<p>if (ende== &quot;n&quot;)<br />
{<br />
system(&quot;cls&quot;);<br />
goto start;<br />
}</p>
<p>}</p>
<p>float Addieren (float a, float b)<br />
{float c = a + b;<br />
return c;}</p>
<p>float Subtrahieren (float a, float b)<br />
{float c = a - b;<br />
return c;}</p>
<p>float Multiplizieren (float a, float b)<br />
{float c = a * b;<br />
return c;}</p>
<p>float Dividieren (float a, float b)<br />
{float c = a / b;<br />
return c;}</p>
<p>float Wurzel (float a, float b)<br />
{float c = pow (a ,1/b);<br />
return c;}</p>
<p>float Potenzieren (float a, float b)<br />
{float c = pow (a,b);<br />
return c;}</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/159247/c-taschenrechner</link><generator>RSS for Node</generator><lastBuildDate>Thu, 10 Sep 2026 08:08:38 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/159247.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 13 Sep 2006 10:13:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to C++ Taschenrechner on Wed, 13 Sep 2006 10:13:20 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>wir machen in der schule c++ im programm Dev-C++<br />
wir programmieren jetzt einen taschenrechner das an sich auch kein großes problem ist aber jetzt soll die ganze eingabe in einer zeile erfolgen...<br />
also soll man schreiben : 5 + 5 = 10<br />
und das in einer zeile....</p>
<p>das bekomme ich leider nicht hin .... könnte mir jemand den folgenden code so umschreiben das es funktioniert??</p>
<p>schonmal danke im vorraus</p>
<p>lohminio</p>
<p>code</p>
<p>#include &lt;iostream&gt;<br />
#include &lt;math.h&gt;</p>
<p>using namespace std;</p>
<p>float Addieren (float a, float b);<br />
float Subtrahieren (float a, float b);<br />
float Multiplizieren (float a, float b);<br />
float Dividieren (float a, float b);<br />
float Wurzel (float a, float b);<br />
float Potenzieren (float a, float b);</p>
<p>main() {<br />
// Dekla<br />
start:<br />
float a,b,c;<br />
int Rechenart ;</p>
<p>// Menü<br />
cout &lt;&lt; &quot;Taschenrechner\n&quot; &lt;&lt; endl;<br />
cout &lt;&lt; &quot;Waehlen Sie die Rechenart:\n&quot; &lt;&lt; endl;</p>
<p>cout &lt;&lt; &quot;[1] Addieren&quot; &lt;&lt; endl;</p>
<p>cout &lt;&lt; &quot;[2] Subtrahieren&quot; &lt;&lt; endl;</p>
<p>cout &lt;&lt; &quot;[3] Multiplizieren&quot; &lt;&lt; endl;</p>
<p>cout &lt;&lt; &quot;[4] Dividieren&quot; &lt;&lt; endl;</p>
<p>cout &lt;&lt; &quot;[5] Wurzel&quot; &lt;&lt; endl;</p>
<p>cout &lt;&lt; &quot;[6] Potenzieren&quot; &lt;&lt; endl;</p>
<p>cout &lt;&lt; &quot;Rechenart??&quot; &lt;&lt; endl;<br />
cin &gt;&gt; Rechenart;</p>
<p>//zahlen eingeben<br />
cout &lt;&lt; &quot;Zahl a eingeben: &quot;;<br />
cin &gt;&gt; a;<br />
cout &lt;&lt; &quot;Zahl b eingeben: &quot;;<br />
cin &gt;&gt; b;</p>
<p>//berechnen<br />
if (Rechenart == 1)<br />
{<br />
c = Addieren(a,b);<br />
cout &lt;&lt; &quot;Ergebnis = &quot; &lt;&lt; c;<br />
}</p>
<p>if (Rechenart == 2)<br />
{<br />
c = Subtrahieren (a,b);<br />
cout &lt;&lt; &quot;Ergebnis = &quot;&lt;&lt; c;<br />
}</p>
<p>if (Rechenart == 3)<br />
{<br />
c = Multiplizieren (a,b);<br />
cout &lt;&lt; &quot;Ergebnis = &quot;&lt;&lt; c;<br />
}</p>
<p>if (Rechenart == 4)<br />
{<br />
c = Dividieren (a,b);<br />
cout &lt;&lt; &quot;Ergebnis = &quot; &lt;&lt; c;<br />
}</p>
<p>if (Rechenart == 5)<br />
{<br />
c = Wurzel (a,b);<br />
cout &lt;&lt; &quot;Ergebnis = &quot; &lt;&lt; c;<br />
}</p>
<p>if (Rechenart == 6)<br />
{<br />
c = Potenzieren(a,b);<br />
cout &lt;&lt; &quot;Ergenis = &quot; &lt;&lt; c;<br />
}</p>
<p>string ende;<br />
cin &gt;&gt; ende;</p>
<p>if (ende== &quot;n&quot;)<br />
{<br />
system(&quot;cls&quot;);<br />
goto start;<br />
}</p>
<p>}</p>
<p>float Addieren (float a, float b)<br />
{float c = a + b;<br />
return c;}</p>
<p>float Subtrahieren (float a, float b)<br />
{float c = a - b;<br />
return c;}</p>
<p>float Multiplizieren (float a, float b)<br />
{float c = a * b;<br />
return c;}</p>
<p>float Dividieren (float a, float b)<br />
{float c = a / b;<br />
return c;}</p>
<p>float Wurzel (float a, float b)<br />
{float c = pow (a ,1/b);<br />
return c;}</p>
<p>float Potenzieren (float a, float b)<br />
{float c = pow (a,b);<br />
return c;}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1136481</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1136481</guid><dc:creator><![CDATA[Lohminio]]></dc:creator><pubDate>Wed, 13 Sep 2006 10:13:20 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Taschenrechner on Wed, 13 Sep 2006 10:23:49 GMT]]></title><description><![CDATA[<p>Lohminio schrieb:</p>
<blockquote>
<p>könnte mir jemand den folgenden code so umschreiben das es funktioniert??</p>
</blockquote>
<p>Was bezahlst du denn dafür? Eine Ingenieurs-Stunde kostet in unserem Unternehmen ca. 170€ ...</p>
<p>Lohminio schrieb:</p>
<blockquote>
<p>also soll man schreiben : 5 + 5 = 10</p>
</blockquote>
<p>Wohl eher '5 + 5'.</p>
<p>Du liest die Eingabe von der Konsole und speicherst sie in einem String. Dann musst du den String zerlegen und in die einzelnen Komponenten zerteilen (Operanden, Operationen).</p>
<p>Damit kannst du dann die gewünschte Operation ausführen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1136488</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1136488</guid><dc:creator><![CDATA[DarthZiu]]></dc:creator><pubDate>Wed, 13 Sep 2006 10:23:49 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Taschenrechner on Wed, 13 Sep 2006 10:51:23 GMT]]></title><description><![CDATA[<p>hey ich schließe mich lohminio an, kenn ihn ja persönlich <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="😉"
    /><br />
Wie is mir das nun möglich die rechenoperation in eine zeile zu schreiben sprich : 5+5 = 10 ! das ich string zerlegen muss is klar bloß wie kann das jemand an einem BSP erklären ?!? wäre echt nett<br />
Mein Quelltext:</p>
<p>// Taschenrechner</p>
<p>// includes<br />
#include&lt;iostream&gt; // Ein - und Ausgabeoperationen<br />
#include&lt;conio.h&gt; // Funktion 'getch()'</p>
<p>using namespace std;</p>
<p>double Addition(double x, double y);<br />
double Subtraktion(double x, double y);<br />
double Multiplikation(double x, double y);<br />
double Division(double x, double y);</p>
<p>int main() {<br />
cout &lt;&lt; &quot;Taschenrechner&quot; &lt;&lt; endl &lt;&lt; endl;</p>
<p>// 1. Zahl<br />
double zahl_1;<br />
cout &lt;&lt; &quot;1. Zahl: &quot;;<br />
cin &gt;&gt; zahl_1;</p>
<p>// 2. Zahl<br />
double zahl_2;<br />
cout &lt;&lt; &quot;\n2. Zahl: &quot;;<br />
cin &gt;&gt; zahl_2;</p>
<p>// Operation<br />
char operation;<br />
cout &lt;&lt; &quot;\nOperation ( '+', '-', '*', '/' ): &quot;;<br />
cin &gt;&gt; operation;</p>
<p>// Auswertung der Eingabe<br />
double ergebnis = 0;</p>
<p>switch(operation) {<br />
case '+' : ergebnis = Addition(zahl_1, zahl_2); break;<br />
case '-' : ergebnis = Subtraktion(zahl_1, zahl_2); break;<br />
case '*' : ergebnis = Multiplikation(zahl_1, zahl_2); break;<br />
case '/' : ergebnis = Division(zahl_1, zahl_2); break;<br />
default : cout &lt;&lt; &quot;Ungueltige Eingabe&quot; &lt;&lt; endl; break;<br />
}</p>
<p>// Anzeigen des Ergebnisses<br />
cout &lt;&lt; &quot;\n&gt;&gt; &quot; &lt;&lt; ergebnis &lt;&lt; endl &lt;&lt; endl;</p>
<p>// Verhindern, dass sich die Konsole automatisch schließt<br />
getch();<br />
}</p>
<p>// Funktionsimplementationen<br />
double Addition(double x, double y) {<br />
double summe = x + y;<br />
return summe;<br />
}</p>
<p>double Subtraktion(double x, double y) {<br />
double differenz = x - y;<br />
return differenz;<br />
}</p>
<p>double Multiplikation(double x, double y) {<br />
double produkt = x * y;<br />
return produkt;<br />
}</p>
<p>double Division(double x, double y) {<br />
double quotient = x / y;<br />
return quotient;<br />
}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1136509</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1136509</guid><dc:creator><![CDATA[Berliner]]></dc:creator><pubDate>Wed, 13 Sep 2006 10:51:23 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Taschenrechner on Wed, 13 Sep 2006 10:58:37 GMT]]></title><description><![CDATA[<p>hehe sowas?</p>
<pre><code class="language-cpp">int main(int argc, char* argv[])
{
double number1,number2,result;
char operator1;

cin&gt;&gt;number1&gt;&gt;operator1&gt;&gt;number2;

switch(operator1)
{
 case 43: result = number1+number2;break;
 case 45: result = number1-number2;break;
 case 42: result = number1*number2;break;
 case 47: result = number1/number2;break;
 default: result = 0;
}
cout&lt;&lt;result;
getch();
        return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1136516</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1136516</guid><dc:creator><![CDATA[ser1al]]></dc:creator><pubDate>Wed, 13 Sep 2006 10:58:37 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Taschenrechner on Wed, 13 Sep 2006 11:07:22 GMT]]></title><description><![CDATA[<p>ser1al schrieb:</p>
<blockquote>
<p>hehe sowas?</p>
</blockquote>
<p>Musst du da nicht die Eingabe jedes 'Tokens' mit Enter bestätigen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1136527</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1136527</guid><dc:creator><![CDATA[DarthZiu]]></dc:creator><pubDate>Wed, 13 Sep 2006 11:07:22 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Taschenrechner on Wed, 13 Sep 2006 11:13:16 GMT]]></title><description><![CDATA[<p>DarthZiu schrieb:</p>
<blockquote>
<p>ser1al schrieb:</p>
<blockquote>
<p>hehe sowas?</p>
</blockquote>
<p>Musst du da nicht die Eingabe jedes 'Tokens' mit Enter bestätigen?</p>
</blockquote>
<p>nee, allerdings kann man nur 2 zahlen eingeben</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1136532</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1136532</guid><dc:creator><![CDATA[ser1al]]></dc:creator><pubDate>Wed, 13 Sep 2006 11:13:16 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Taschenrechner on Wed, 13 Sep 2006 11:24:57 GMT]]></title><description><![CDATA[<p>hey jungs thx erst mal bloß wie wende ich das jetz auf mein quelltext an ? kann das mal jemand beispielsweise in meinen Code einfügen? ich brauch das für morgen und mir gehen die ideen aus und im i-net findet man nix gutes bzw nix was für mich als C++ anfänger verständlich ist!</p>
<p>wäre echt nett jungs ihr rettet mir damit den hals! bis dann</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1136539</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1136539</guid><dc:creator><![CDATA[Berliner]]></dc:creator><pubDate>Wed, 13 Sep 2006 11:24:57 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Taschenrechner on Wed, 13 Sep 2006 11:28:57 GMT]]></title><description><![CDATA[<p>???</p>
<p>das beispiel ist doch voll funktionsfähig!<br />
was willst da noch haben?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1136546</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1136546</guid><dc:creator><![CDATA[ser1al]]></dc:creator><pubDate>Wed, 13 Sep 2006 11:28:57 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Taschenrechner on Wed, 13 Sep 2006 11:30:35 GMT]]></title><description><![CDATA[<p>Davon mal abgesehen ist das einzige was anders ist die Eingabe (um die geht es immerhin), das Brimborium drumherum (&quot;Bitte geben sie....&quot;) und die Auslagerung der Rechenoperationen in Funktionen. Und ein bisschen selbst denken ist durchaus auch in der Schule erlaubt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1136547</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1136547</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Wed, 13 Sep 2006 11:30:35 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Taschenrechner on Wed, 13 Sep 2006 11:54:43 GMT]]></title><description><![CDATA[<p>das diese funktion mit meinen Prog bzw quelltext zusammen kommt das will ich! will die struktur wenn möglich behalten es soll nun aber so sein das ich nicht gezwungen bin erst 5 einzugeben dies mit enter bestätigen dann die rechenoperation diese widerrum bestätigen mit enter und dann die zahl 2 diese muss ich ja jetz noch mit enter bestätigen! das soll ja alles weg es soll sein das ich alles in eine zeile schreiben kann und er mir dann das ergebnis raushaut das passiert mit der string zerlegung das is klar aber ich bin der total anfänger in c++ bin froh das ich den quelltext für den taschenrechner so hinbekommen habe! und wie muss ich was deklarieren kein plan jungs helft mir weiß nicht weiter mit platzt sonst noch der kopf</p>
<p>ach und muss ich noch was includen ? wenn ja was ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1136563</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1136563</guid><dc:creator><![CDATA[Berliner]]></dc:creator><pubDate>Wed, 13 Sep 2006 11:54:43 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Taschenrechner on Wed, 13 Sep 2006 12:08:49 GMT]]></title><description><![CDATA[<p>so, aber das das nicht zur gewohnheit wird</p>
<pre><code class="language-cpp">#include&lt;iostream&gt; // Ein - und Ausgabeoperationen
#include&lt;conio.h&gt; // Funktion 'getch()'

using namespace std;

double Addition(double x, double y);
double Subtraktion(double x, double y);
double Multiplikation(double x, double y);
double Division(double x, double y);

int main() {
cout &lt;&lt; &quot;Taschenrechner&quot; &lt;&lt; endl &lt;&lt; endl;

//zahlen und operator
double zahl_1,zahl_2;
char operation;

cout&lt;&lt;&quot;Geben Sie nun den zu berechnenden Term ein:&quot;&lt;&lt;endl;
cout&lt;&lt;&quot;&gt;&quot;;
cin&gt;&gt;zahl_1&gt;&gt;operation&gt;&gt;zahl_2;

// Auswertung der Eingabe
double ergebnis = 0;

switch(operation) {
case 43 : ergebnis = Addition(zahl_1, zahl_2); break;
case 45 : ergebnis = Subtraktion(zahl_1, zahl_2); break;
case 42 : ergebnis = Multiplikation(zahl_1, zahl_2); break;
case 47 : ergebnis = Division(zahl_1, zahl_2); break;
default : cout &lt;&lt; &quot;Ungueltige Eingabe&quot; &lt;&lt; endl; break;
}

// Anzeigen des Ergebnisses
cout &lt;&lt; &quot;\n&gt;&gt; &quot; &lt;&lt; ergebnis &lt;&lt; endl &lt;&lt; endl;

// Verhindern, dass sich die Konsole automatisch schließt
getch();
}

// Funktionsimplementationen
double Addition(double x, double y) {
double summe = x + y;
return summe;
}

double Subtraktion(double x, double y) {
double differenz = x - y;
return differenz;
}

double Multiplikation(double x, double y) {
double produkt = x * y;
return produkt;
}

double Division(double x, double y) {
double quotient = x / y;
return quotient;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1136576</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1136576</guid><dc:creator><![CDATA[ser1al]]></dc:creator><pubDate>Wed, 13 Sep 2006 12:08:49 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Taschenrechner on Wed, 13 Sep 2006 13:30:16 GMT]]></title><description><![CDATA[<p>jo thx erstnal @ all,</p>
<p>so wie es da ist is das nun mit strings zerlegen gelöst ? oder wie ? weil das nächste prob is wenn ich nun noch ne dritte oder ne vierte zahl habe bsp. klammernrechnung wie soll das dann funktionieren? oder wenn ich mehr als diese 4 rechenoperationen z.B. wurzel potenz usw....</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1136658</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1136658</guid><dc:creator><![CDATA[Berliner]]></dc:creator><pubDate>Wed, 13 Sep 2006 13:30:16 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Taschenrechner on Wed, 13 Sep 2006 13:34:02 GMT]]></title><description><![CDATA[<p>wenn du mehr als 2 zahlen brauchst, musst dann eben parsen (zerlegen)<br />
da musst dir dann aber schon langsam mal selber einen kopf machen!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1136660</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1136660</guid><dc:creator><![CDATA[ser1al]]></dc:creator><pubDate>Wed, 13 Sep 2006 13:34:02 GMT</pubDate></item></channel></rss>