<?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[Summenzusammenrechnen und Fakultäten]]></title><description><![CDATA[<p>Hallo Chummerz,<br />
wäre nett wenn mir jemand bei der Summenrechnung helfen könnte. Haben den Auftrag in der Schule bekommen und ich habe immer hin schon hinbekommen das er die Fakultäten richtig berechnet... nur weiter komme ich einfach nicht.<br />
Mein bisheriger Quellcode:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;stdlib.h&gt;
using namespace std;

int menu(int);
int rechn(int, int);
int fak(int);

int main()
{
	int mennu=0, a, b, c;

	do
	{
		c = menu(mennu);

		switch (c)
		{
		case 1: cout &lt;&lt; &quot;Bitte geben Sie n1 ein:\t&quot;;
				cin &gt;&gt; a;
				cout &lt;&lt; &quot;Bitte geben Sie n2 ein:\t&quot;;
				cin &gt;&gt; b;
				rechn(a, b);
                cin.get(); cin.get();
				break;
		case 2: cout &lt;&lt; &quot;Bitte geben Sie n! ein:\t&quot;;
				cin &gt;&gt; a;
				fak (a);
                cin.get(); cin.get();
				break;
		}
	} while (c &lt;= 2);
	return 0;
}

int menu(int mennu)
{
		system(&quot;cls&quot;);
		cout &lt;&lt; &quot;---------------------------------------------\n&quot;
			 &lt;&lt; &quot;           --- Schleifen ---            \n&quot;
			 &lt;&lt; &quot;---------------------------------------------\n\n&quot;
			 &lt;&lt; &quot;Grundrechenarten\n\n&quot;
			 &lt;&lt; &quot;\t1\t- Zusammenrechnung n1 bis n2\n&quot;
			 &lt;&lt; &quot;\t2\t- Fakultätenrechnung n!\n\n&quot;
			 &lt;&lt; &quot;\tsonst\t- Programmbeenden\n\n&quot;
			 &lt;&lt; &quot;\tBitte Ihre Auswahl eingeben: &quot;;		
		cin &gt;&gt; mennu;
		cout &lt;&lt; &quot;\n\n&quot;;

		return mennu;
}

int rechn(int a, int b)
{
    int summe;
    cout &lt;&lt; &quot;Berechnung der Summe von &quot; &lt;&lt; a &lt;&lt; &quot; bis &quot; &lt;&lt; b &lt;&lt; endl;
	if (b&gt;=a)
	{
             for (int i = 1; i &lt;= b; i++)
             {
                 summe += i;
             }
    }
    else
        cout &lt;&lt; &quot;Der Wert von n2 muss groesser sein, als der von n1!&quot; &lt;&lt; endl;
    return 0;
}

int fak(int a)
{
    int fak = 1;

    for (int i = 2; i &lt;= a; i++)
    {
        fak = fak * i;
    }

    cout &lt;&lt; &quot;Die Fakultaet von &quot; &lt;&lt; a &lt;&lt; &quot; ist: &quot; &lt;&lt; fak &lt;&lt; &quot;!\n&quot;;
    return 0;    
}
</code></pre>
<p>Es funktioniert bisher alles, ausser die Summenzusammenrechnung.<br />
Sprich:<br />
n1 = 2<br />
n2 = 4<br />
Summe von n1 und n2 = 2 + 3 + 4 = 9</p>
<p>Danke schonmal für die Hilfe.</p>
<p>so long</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/256074/summenzusammenrechnen-und-fakultäten</link><generator>RSS for Node</generator><lastBuildDate>Fri, 11 Sep 2026 18:09:25 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/256074.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 07 Dec 2009 20:14:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Summenzusammenrechnen und Fakultäten on Mon, 07 Dec 2009 20:14:58 GMT]]></title><description><![CDATA[<p>Hallo Chummerz,<br />
wäre nett wenn mir jemand bei der Summenrechnung helfen könnte. Haben den Auftrag in der Schule bekommen und ich habe immer hin schon hinbekommen das er die Fakultäten richtig berechnet... nur weiter komme ich einfach nicht.<br />
Mein bisheriger Quellcode:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;stdlib.h&gt;
using namespace std;

int menu(int);
int rechn(int, int);
int fak(int);

int main()
{
	int mennu=0, a, b, c;

	do
	{
		c = menu(mennu);

		switch (c)
		{
		case 1: cout &lt;&lt; &quot;Bitte geben Sie n1 ein:\t&quot;;
				cin &gt;&gt; a;
				cout &lt;&lt; &quot;Bitte geben Sie n2 ein:\t&quot;;
				cin &gt;&gt; b;
				rechn(a, b);
                cin.get(); cin.get();
				break;
		case 2: cout &lt;&lt; &quot;Bitte geben Sie n! ein:\t&quot;;
				cin &gt;&gt; a;
				fak (a);
                cin.get(); cin.get();
				break;
		}
	} while (c &lt;= 2);
	return 0;
}

int menu(int mennu)
{
		system(&quot;cls&quot;);
		cout &lt;&lt; &quot;---------------------------------------------\n&quot;
			 &lt;&lt; &quot;           --- Schleifen ---            \n&quot;
			 &lt;&lt; &quot;---------------------------------------------\n\n&quot;
			 &lt;&lt; &quot;Grundrechenarten\n\n&quot;
			 &lt;&lt; &quot;\t1\t- Zusammenrechnung n1 bis n2\n&quot;
			 &lt;&lt; &quot;\t2\t- Fakultätenrechnung n!\n\n&quot;
			 &lt;&lt; &quot;\tsonst\t- Programmbeenden\n\n&quot;
			 &lt;&lt; &quot;\tBitte Ihre Auswahl eingeben: &quot;;		
		cin &gt;&gt; mennu;
		cout &lt;&lt; &quot;\n\n&quot;;

		return mennu;
}

int rechn(int a, int b)
{
    int summe;
    cout &lt;&lt; &quot;Berechnung der Summe von &quot; &lt;&lt; a &lt;&lt; &quot; bis &quot; &lt;&lt; b &lt;&lt; endl;
	if (b&gt;=a)
	{
             for (int i = 1; i &lt;= b; i++)
             {
                 summe += i;
             }
    }
    else
        cout &lt;&lt; &quot;Der Wert von n2 muss groesser sein, als der von n1!&quot; &lt;&lt; endl;
    return 0;
}

int fak(int a)
{
    int fak = 1;

    for (int i = 2; i &lt;= a; i++)
    {
        fak = fak * i;
    }

    cout &lt;&lt; &quot;Die Fakultaet von &quot; &lt;&lt; a &lt;&lt; &quot; ist: &quot; &lt;&lt; fak &lt;&lt; &quot;!\n&quot;;
    return 0;    
}
</code></pre>
<p>Es funktioniert bisher alles, ausser die Summenzusammenrechnung.<br />
Sprich:<br />
n1 = 2<br />
n2 = 4<br />
Summe von n1 und n2 = 2 + 3 + 4 = 9</p>
<p>Danke schonmal für die Hilfe.</p>
<p>so long</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1819245</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1819245</guid><dc:creator><![CDATA[Althi]]></dc:creator><pubDate>Mon, 07 Dec 2009 20:14:58 GMT</pubDate></item><item><title><![CDATA[Reply to Summenzusammenrechnen und Fakultäten on Mon, 07 Dec 2009 20:19:30 GMT]]></title><description><![CDATA[<p>Du hast da ja keine Ausgabe der Summe. Ist das vlt. das, was du meinst?</p>
<p>btw:</p>
<pre><code class="language-cpp">if (b&gt;=a)
    {
             for (int i = 1; i &lt;= b; i++)
             {
                 summe += i;
             }
    }
</code></pre>
<p>Müsstest du hier nicht eher bei a anfangen? also:</p>
<pre><code class="language-cpp">if (b&gt;=a)
    {
             for (int i = a; i &lt;= b; i++)
             {
                 summe += i;
             }
    }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1819250</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1819250</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Mon, 07 Dec 2009 20:19:30 GMT</pubDate></item></channel></rss>