<?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[Programm für Mittelwertsberechnung]]></title><description><![CDATA[<p>Hi,</p>
<p>wir haben in der Schule eine Aufgabe bekommen und zwar soll folgendes Programm geschrieben werden:</p>
<p>- Abfrage wieviel Zahlen eingelesen werden sollen<br />
- Zahlen nacheinander abfragen<br />
- Aus diesen Zahlen den Mittelwert berechnen!</p>
<p>Das ganze soll mit Hilfe der do...while Schleife passieren weil wir die grad durchnehmen. Da ich aber schon mal C++ in ner anderen Schulform hatte, ist dies doch ohne Arrays gar nicht möglich oder? Weil wie soll ich das bitte programmieren... er muss ja dann je nach dem wieviel zahlen eingelesen werden auch so und so viel variablen reservieren damit er sich die zahlen, die dann später eingebene werden, merkt und aus diese dann den mittelwert berechnet! also ich bin da ein wenig überfordert vielleicht denk ich auch zu kompliziert... wär nett wenn jmd. mir helfen könnte!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/148106/programm-für-mittelwertsberechnung</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Sep 2026 15:26:22 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/148106.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 23 May 2006 13:05:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Programm für Mittelwertsberechnung on Tue, 23 May 2006 13:05:37 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>wir haben in der Schule eine Aufgabe bekommen und zwar soll folgendes Programm geschrieben werden:</p>
<p>- Abfrage wieviel Zahlen eingelesen werden sollen<br />
- Zahlen nacheinander abfragen<br />
- Aus diesen Zahlen den Mittelwert berechnen!</p>
<p>Das ganze soll mit Hilfe der do...while Schleife passieren weil wir die grad durchnehmen. Da ich aber schon mal C++ in ner anderen Schulform hatte, ist dies doch ohne Arrays gar nicht möglich oder? Weil wie soll ich das bitte programmieren... er muss ja dann je nach dem wieviel zahlen eingelesen werden auch so und so viel variablen reservieren damit er sich die zahlen, die dann später eingebene werden, merkt und aus diese dann den mittelwert berechnet! also ich bin da ein wenig überfordert vielleicht denk ich auch zu kompliziert... wär nett wenn jmd. mir helfen könnte!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1063504</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1063504</guid><dc:creator><![CDATA[andy_cux]]></dc:creator><pubDate>Tue, 23 May 2006 13:05:37 GMT</pubDate></item><item><title><![CDATA[Reply to Programm für Mittelwertsberechnung on Tue, 23 May 2006 13:09:29 GMT]]></title><description><![CDATA[<p>Du brauchst kein Array. Du brauchst nur die Summe und die Anzahl, und die kannst du während der Eingabe aktualisieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1063509</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1063509</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Tue, 23 May 2006 13:09:29 GMT</pubDate></item><item><title><![CDATA[Reply to Programm für Mittelwertsberechnung on Tue, 23 May 2006 13:13:59 GMT]]></title><description><![CDATA[<p>ja aber angenommen ich geb ein 3 zahlen sollen eingelesne werden dann brauch ich ja 3 variablen... wenn ich 5 eingebe 5 variablen... weil irgendwo muss er sich ja die eingegeben zahlen später merken und addieren... arg ich denk bestimmt wieder viel zu kompliziert ^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1063514</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1063514</guid><dc:creator><![CDATA[andy_cux]]></dc:creator><pubDate>Tue, 23 May 2006 13:13:59 GMT</pubDate></item><item><title><![CDATA[Reply to Programm für Mittelwertsberechnung on Tue, 23 May 2006 13:15:25 GMT]]></title><description><![CDATA[<p>Du musst doch nur immer die &quot;neue&quot; Zahl dazu addieren</p>
<pre><code class="language-cpp">int Zahl;
int Gesamt;

Gesamt += Zahl;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1063515</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1063515</guid><dc:creator><![CDATA[EEK]]></dc:creator><pubDate>Tue, 23 May 2006 13:15:25 GMT</pubDate></item><item><title><![CDATA[Reply to Programm für Mittelwertsberechnung on Tue, 23 May 2006 13:17:20 GMT]]></title><description><![CDATA[<p>ja, du denkst zu kompliziert <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="🙂"
    /> es geht auch leichter <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>
<p>stell dir vor, wie du es persönlich rechnen würdest, wenn du von 100zahlen den durchschnitt bilden müsstest, aber nur eine zahl nach der anderen siehst. du darfst dir aber nich alle zahlen aufschreiben <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/1063518</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1063518</guid><dc:creator><![CDATA[Maxi]]></dc:creator><pubDate>Tue, 23 May 2006 13:17:20 GMT</pubDate></item><item><title><![CDATA[Reply to Programm für Mittelwertsberechnung on Tue, 23 May 2006 13:18:13 GMT]]></title><description><![CDATA[<p>ja ich glaub ich habs <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="😉"
    /> mach mich gleich mal ran und hakk das in nen code rein... mal schauen obs dann auch funzt! merci <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/1063519</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1063519</guid><dc:creator><![CDATA[andy_cux]]></dc:creator><pubDate>Tue, 23 May 2006 13:18:13 GMT</pubDate></item><item><title><![CDATA[Reply to Programm für Mittelwertsberechnung on Tue, 23 May 2006 13:20:56 GMT]]></title><description><![CDATA[<p>Falls Du die Zahlen aus irgendeinem Grund trotzdem in einem Array zwischenspeichern willst, lässt sich das ohne Probleme mittels Reservierung von Heap-Speicher realisieren:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

int main()
{
    int anzahl = 0;
    int *zahlen;

    cout &lt;&lt; &quot;Wieviele Zahlen?&quot; &lt;&lt; endl;
    cin &gt;&gt; anzahl;

    zahlen = new int[anzahl]; //Speicher für das Array auf dem Heap reservieren

    //zahlen einlesen und damit rummachen

    delete [] zahlen; //auf dem Heap reservierten Array-Speicher freigeben
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1063521</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1063521</guid><dc:creator><![CDATA[schorsch code]]></dc:creator><pubDate>Tue, 23 May 2006 13:20:56 GMT</pubDate></item><item><title><![CDATA[Reply to Programm für Mittelwertsberechnung on Tue, 23 May 2006 13:42:42 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

int main()
{
    int n=0,anzahl,zahl,summe,mittel;
    cout &lt;&lt; &quot;Mittelwertsberechnung&quot; &lt;&lt; endl;
    cout &lt;&lt; &quot;Wieviel Zahlen moechten Sie eingeben?: &quot;;
    cin &gt;&gt; anzahl;
    if (anzahl &lt;= 0)
       cout &lt;&lt; &quot;Fehler! Bitte neustarten!&quot;;
    else
    do
    {
        cout &lt;&lt; &quot;Bitte Zahl eingeben: &quot;;
        cin &gt;&gt; zahl;
        summe=+zahl;
        n++;
    }
    while (n==anzahl);
    mittel=summe/anzahl;
    cout &lt;&lt; &quot;Der Mittelwert betraegt: &quot; &lt;&lt; mittel;
    return 0;
}
</code></pre>
<p>irgendwie will das noch net so ganz...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1063535</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1063535</guid><dc:creator><![CDATA[andy_cux]]></dc:creator><pubDate>Tue, 23 May 2006 13:42:42 GMT</pubDate></item><item><title><![CDATA[Reply to Programm für Mittelwertsberechnung on Tue, 23 May 2006 13:44:55 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

int main(){

int Zahl = 0;
int Gesamt = 0;

do {
cout &lt;&lt; &quot;\nZahl eingeben: &quot;;
cin &gt;&gt; Zahl;
Gesamt += Zahl;
}
while (Zahl &lt; 100; Zahl++);{
cout &lt;&lt; &quot;Wieviele Zahlen sollen eingelesen werden?&quot; &lt;&lt; endl;
}

return 0;
}
</code></pre>
<p>hab jetzt ned compiliert.. funzt es?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1063538</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1063538</guid><dc:creator><![CDATA[The-Davinci-Decode]]></dc:creator><pubDate>Tue, 23 May 2006 13:44:55 GMT</pubDate></item><item><title><![CDATA[Reply to Programm für Mittelwertsberechnung on Tue, 23 May 2006 13:48:57 GMT]]></title><description><![CDATA[<p>den ersten fehler hab ich entdeckt in meinem code</p>
<pre><code class="language-cpp">while (n!=anzahl)
</code></pre>
<p>muss es heissen ^^ aber danach beendet er das programm und macht nicht weiter nachdem die schleife abgelaufen ist</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1063540</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1063540</guid><dc:creator><![CDATA[andy_cux]]></dc:creator><pubDate>Tue, 23 May 2006 13:48:57 GMT</pubDate></item><item><title><![CDATA[Reply to Programm für Mittelwertsberechnung on Tue, 23 May 2006 13:51:18 GMT]]></title><description><![CDATA[<p>andy_cux schrieb:</p>
<blockquote>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

int main()
{
    int n=0,anzahl,zahl,summe,mittel;
    cout &lt;&lt; &quot;Mittelwertsberechnung&quot; &lt;&lt; endl;
    cout &lt;&lt; &quot;Wieviel Zahlen moechten Sie eingeben?: &quot;;
    cin &gt;&gt; anzahl;
    if (anzahl &lt;= 0)
       cout &lt;&lt; &quot;Fehler! Bitte neustarten!&quot;;
    else
    do
    {
        cout &lt;&lt; &quot;Bitte Zahl eingeben: &quot;;
        cin &gt;&gt; zahl;
        summe=+zahl;
        n++;
    }
    while (n==anzahl);
    mittel=summe/anzahl;
    cout &lt;&lt; &quot;Der Mittelwert betraegt: &quot; &lt;&lt; mittel;
    return 0;
}
</code></pre>
<p>irgendwie will das noch net so ganz...</p>
</blockquote>
<p>Das</p>
<pre><code class="language-cpp">while(n==anzahl);
</code></pre>
<p>wird so nicht funktionieren weil du darauf prüfst ob es gleich anzahl ist.<br />
und es heißt auch nicht =+ sonder +=</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1063544</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1063544</guid><dc:creator><![CDATA[EEK]]></dc:creator><pubDate>Tue, 23 May 2006 13:51:18 GMT</pubDate></item><item><title><![CDATA[Reply to Programm für Mittelwertsberechnung on Tue, 23 May 2006 13:53:30 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

int main()
{
    int n=0,anzahl,zahl,summe=0,mittel;
    cout &lt;&lt; &quot;Mittelwertsberechnung&quot; &lt;&lt; endl;
    cout &lt;&lt; &quot;\nWieviel Zahlen moechten Sie eingeben?: &quot;;
    cin &gt;&gt; anzahl;
    if (anzahl &lt;= 0)
       cout &lt;&lt; &quot;Fehler! Bitte neustarten!&quot;;
    else
    do
    {
        cout &lt;&lt; &quot;Bitte Zahl eingeben: &quot;;
        cin &gt;&gt; zahl;
        summe+=zahl;
        n++;
    }
    while (n!=anzahl);
    mittel=summe/anzahl;
    cout &lt;&lt; &quot;Der Mittelwert betraegt: &quot; &lt;&lt; mittel;
    return 0;
    system(&quot;PAUSE&quot;);
}
</code></pre>
<p>hm nach der eingabe der zahlen schließt das programm <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> und das system pause ist nur drin da ich hier auf der arberit nur dev c++ hab und das hat die tolle funktion &quot;press any key to close the programm&quot; wie bei borland nich sondern beendet sofort... aber trotzdem geth dis prog noch net und ich hab keine ahnung wieso</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1063546</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1063546</guid><dc:creator><![CDATA[andy_cux]]></dc:creator><pubDate>Tue, 23 May 2006 13:53:30 GMT</pubDate></item><item><title><![CDATA[Reply to Programm für Mittelwertsberechnung on Tue, 23 May 2006 14:06:56 GMT]]></title><description><![CDATA[<p>ok es funzt! das system(&quot;Pause&quot;) musste nur vor dem return 0;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1063563</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1063563</guid><dc:creator><![CDATA[andy_cux]]></dc:creator><pubDate>Tue, 23 May 2006 14:06:56 GMT</pubDate></item><item><title><![CDATA[Reply to Programm für Mittelwertsberechnung on Wed, 24 May 2006 10:12:17 GMT]]></title><description><![CDATA[<p>Grüßgott..</p>
<p>Meine lautet:<br />
Wieso man in der DO Schleife die Variable <strong>n</strong> inkrementiert?<br />
<em>n++;</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1064088</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1064088</guid><dc:creator><![CDATA[The_Davinci_Decode]]></dc:creator><pubDate>Wed, 24 May 2006 10:12:17 GMT</pubDate></item><item><title><![CDATA[Reply to Programm für Mittelwertsberechnung on Wed, 24 May 2006 10:21:38 GMT]]></title><description><![CDATA[<p>The_Davinci_Decode schrieb:</p>
<blockquote>
<p>Grüßgott..</p>
<p>Meine lautet:<br />
Wieso man in der DO Schleife die Variable <strong>n</strong> inkrementiert?<br />
<em>n++;</em></p>
</blockquote>
<p>Damit die Schleife funktioniert, also damit die Schleife nur so lange läuft bis n gleich anzahl ist</p>
<pre><code class="language-cpp">while (n!=anzahl);
</code></pre>
<p>oder was meinst du mit</p>
<p>The_Davinci_Decode schrieb:</p>
<blockquote>
<p>Meine lautet:</p>
</blockquote>
<p>?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1064098</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1064098</guid><dc:creator><![CDATA[EEK]]></dc:creator><pubDate>Wed, 24 May 2006 10:21:38 GMT</pubDate></item><item><title><![CDATA[Reply to Programm für Mittelwertsberechnung on Wed, 24 May 2006 10:24:42 GMT]]></title><description><![CDATA[<p>^^</p>
<p>meinte eigentlich &quot;Meine Frage lautet:&quot;</p>
<p>naja ich check den Sinn garnicht. Wieso soll n nicht gleich anzahl sein?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1064100</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1064100</guid><dc:creator><![CDATA[The_Davinci_Decode]]></dc:creator><pubDate>Wed, 24 May 2006 10:24:42 GMT</pubDate></item><item><title><![CDATA[Reply to Programm für Mittelwertsberechnung on Wed, 24 May 2006 10:28:01 GMT]]></title><description><![CDATA[<p>Die Schleife soll solange laufen, bis 'anzahl' Zahlen eingegeben wurden. Also zählt man von 0 aus durch, wieviele Zahlen schon da waren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1064104</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1064104</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 24 May 2006 10:28:01 GMT</pubDate></item><item><title><![CDATA[Reply to Programm für Mittelwertsberechnung on Wed, 24 May 2006 10:32:02 GMT]]></title><description><![CDATA[<p>Es wird beim Programmstart vom Benutzer abgefragt wie viele Zahlen eingebenen werden sollen. Dieser Wert wird in der Variable &quot;anzahl&quot; gespeichert. Die Varialble &quot;n&quot; wird bei jedem Schleifendurchlauf um 1 mit n++ erhöht, und das halt solange bis n gleich anzahl ist und somit sind soviele Zahlen eingegeben worden wie der Benutzer am anfang haben wollte.</p>
<p>EDIT: Oder einfacher gesagt wenn &quot;n&quot; von Anfang an gleich &quot;anzahl&quot; wäre, dann würde die Schleife nie ausgeführt und man könnte keine Zahlen eingeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1064110</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1064110</guid><dc:creator><![CDATA[EEK]]></dc:creator><pubDate>Wed, 24 May 2006 10:32:02 GMT</pubDate></item><item><title><![CDATA[Reply to Programm für Mittelwertsberechnung on Wed, 24 May 2006 17:05:38 GMT]]></title><description><![CDATA[<p>aaahh, so ist das.. vielen thx. verstehe schon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1064436</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1064436</guid><dc:creator><![CDATA[The_Davinci_Decode]]></dc:creator><pubDate>Wed, 24 May 2006 17:05:38 GMT</pubDate></item></channel></rss>