<?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[Wieder mal Referenzen]]></title><description><![CDATA[<p>hallo!</p>
<p>Folgendes Programm soll Minimum, Maximum und Mittelwert aus 10 Eingaben berechnen. Wir sollen 3 Funktionen (Eingabe, Berechnung, Ausgabe) verwenden.<br />
Und für die Eingabe ein Array. Zum schluss bei der Ausgabe sollen alle werte noch mal ausgegeben werden.</p>
<p>Es funktioniert alles, bis auf dass der letzte wert irgend eine hohe zahl ist.<br />
UND: Der Mittelwert wird ohne kommastellen angezeigt.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;conio&gt;

using namespace std;

//---------------------------------------------------------------------------

int eingabe(int iI[9])
 {
 cout &lt;&lt; &quot;Geben Sie 10 Zahlen ein&quot; &lt;&lt; endl &lt;&lt; endl;

 for (int i=0;i&lt;10;i++)
  {
    cout &lt;&lt; &quot;Geben Sie Zahl &quot; &lt;&lt; i + 1 &lt;&lt; &quot; ein: &quot;;
    cin &gt;&gt; iI[i];
  }
 cout &lt;&lt; endl;
 }

int berechnung(int &amp;min, int &amp;max, int iI[9], float &amp;mittel)
 {
 int sum,anz;

 sum = 0;
 anz = 0;

 min = iI[0];
 max = iI[0];

 for (int i=0;i&lt;10;i++)
  {
  anz++;

  if (iI[i] &lt; min) min = iI[i];
  if (iI[i] &gt; max) max = iI[i];

  sum = sum + iI[i];
  }

 mittel = sum/anz;
 }

int ausgabe(int iMin, int iMax, float fMittel, int iI[9])
 {
 cout &lt;&lt; &quot;Die kleinste Zahl ist: &quot; &lt;&lt; iMin &lt;&lt; endl;
 cout &lt;&lt; &quot;Die groesste Zahl ist: &quot; &lt;&lt; iMax &lt;&lt; endl;
 cout &lt;&lt; &quot;Der Mittelwert ist: &quot; &lt;&lt; fMittel &lt;&lt; endl &lt;&lt; endl;

 for (int i=0;i&lt;10;i++)
  {
  cout &lt;&lt; &quot;Eingabe &quot; &lt;&lt; i+1 &lt;&lt; &quot; : &quot; &lt;&lt; iI[i] &lt;&lt; endl;
  }
 }

//---------------------------------------------------------------------------
int main()
 {
 int iEingabe[9], min, max;
 float mittel;

 eingabe(iEingabe);
 berechnung(min, max, iEingabe, mittel);
 ausgabe(min, max, mittel, iEingabe);

 getch();

 return 0;
 }
//---------------------------------------------------------------------------
</code></pre>
<p>bitte um hilfe<br />
danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/165378/wieder-mal-referenzen</link><generator>RSS for Node</generator><lastBuildDate>Mon, 14 Sep 2026 13:26:42 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/165378.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 19 Nov 2006 12:09:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Wieder mal Referenzen on Sun, 19 Nov 2006 12:09:59 GMT]]></title><description><![CDATA[<p>hallo!</p>
<p>Folgendes Programm soll Minimum, Maximum und Mittelwert aus 10 Eingaben berechnen. Wir sollen 3 Funktionen (Eingabe, Berechnung, Ausgabe) verwenden.<br />
Und für die Eingabe ein Array. Zum schluss bei der Ausgabe sollen alle werte noch mal ausgegeben werden.</p>
<p>Es funktioniert alles, bis auf dass der letzte wert irgend eine hohe zahl ist.<br />
UND: Der Mittelwert wird ohne kommastellen angezeigt.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;conio&gt;

using namespace std;

//---------------------------------------------------------------------------

int eingabe(int iI[9])
 {
 cout &lt;&lt; &quot;Geben Sie 10 Zahlen ein&quot; &lt;&lt; endl &lt;&lt; endl;

 for (int i=0;i&lt;10;i++)
  {
    cout &lt;&lt; &quot;Geben Sie Zahl &quot; &lt;&lt; i + 1 &lt;&lt; &quot; ein: &quot;;
    cin &gt;&gt; iI[i];
  }
 cout &lt;&lt; endl;
 }

int berechnung(int &amp;min, int &amp;max, int iI[9], float &amp;mittel)
 {
 int sum,anz;

 sum = 0;
 anz = 0;

 min = iI[0];
 max = iI[0];

 for (int i=0;i&lt;10;i++)
  {
  anz++;

  if (iI[i] &lt; min) min = iI[i];
  if (iI[i] &gt; max) max = iI[i];

  sum = sum + iI[i];
  }

 mittel = sum/anz;
 }

int ausgabe(int iMin, int iMax, float fMittel, int iI[9])
 {
 cout &lt;&lt; &quot;Die kleinste Zahl ist: &quot; &lt;&lt; iMin &lt;&lt; endl;
 cout &lt;&lt; &quot;Die groesste Zahl ist: &quot; &lt;&lt; iMax &lt;&lt; endl;
 cout &lt;&lt; &quot;Der Mittelwert ist: &quot; &lt;&lt; fMittel &lt;&lt; endl &lt;&lt; endl;

 for (int i=0;i&lt;10;i++)
  {
  cout &lt;&lt; &quot;Eingabe &quot; &lt;&lt; i+1 &lt;&lt; &quot; : &quot; &lt;&lt; iI[i] &lt;&lt; endl;
  }
 }

//---------------------------------------------------------------------------
int main()
 {
 int iEingabe[9], min, max;
 float mittel;

 eingabe(iEingabe);
 berechnung(min, max, iEingabe, mittel);
 ausgabe(min, max, mittel, iEingabe);

 getch();

 return 0;
 }
//---------------------------------------------------------------------------
</code></pre>
<p>bitte um hilfe<br />
danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1177054</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1177054</guid><dc:creator><![CDATA[Guest101]]></dc:creator><pubDate>Sun, 19 Nov 2006 12:09:59 GMT</pubDate></item><item><title><![CDATA[Reply to Wieder mal Referenzen on Sun, 19 Nov 2006 13:20:19 GMT]]></title><description><![CDATA[<p>Dein Array iI ist zu klein. Du möchtest 10 Zahlen speichern, hast aber nur 9 Felder angegeben. Richtig wäre &quot;int iEingabe[10]&quot;</p>
<p>Die Kommastellen fehlen, weil du sum/anz als Division ganzer Zahlen rechnest, und erst danach in float konvertiest. Richtig wäre &quot;mittel = (float)sum / anz;&quot;</p>
<p>*edit*<br />
Du brauchst anz gar nicht zu berechnen, weil es ohnehin in jedem Fall 10 ist <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/1177105</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1177105</guid><dc:creator><![CDATA[Neku]]></dc:creator><pubDate>Sun, 19 Nov 2006 13:20:19 GMT</pubDate></item><item><title><![CDATA[Reply to Wieder mal Referenzen on Sun, 19 Nov 2006 15:43:33 GMT]]></title><description><![CDATA[<p>also, normalerweise startet ein ARRAY bei 0..<br />
d.h. iI[9] ist ein Array von 0 bis 9, und das sind 10 zahlen</p>
<p>jetzt funktioniert es aber?!?<br />
muss ich alle arrays als 10 nehmen? oder nur das letzte?</p>
<p>vielen dank</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1177244</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1177244</guid><dc:creator><![CDATA[Guest101]]></dc:creator><pubDate>Sun, 19 Nov 2006 15:43:33 GMT</pubDate></item><item><title><![CDATA[Reply to Wieder mal Referenzen on Sun, 19 Nov 2006 16:28:54 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">typ variable[feldzahl];
</code></pre>
<p>Bei der Deklaration steht in den eckigen Klammern die Anzahl der Felder und das ist eine <strong>Anzahl</strong>, da beginnt nichts bei 0, also musst du in deinem Fall überall 10 verwenden. Erst wenn du auf Elemente der Variable zugreifst, musst du bei 0 anfangen zu zählen. So hat also ein Array mit 10 Feldern (typ x[10]) die Felder 0 bis 9 (x[0] ... x[9]).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1177276</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1177276</guid><dc:creator><![CDATA[Neku]]></dc:creator><pubDate>Sun, 19 Nov 2006 16:28:54 GMT</pubDate></item><item><title><![CDATA[Reply to Wieder mal Referenzen on Mon, 20 Nov 2006 14:05:07 GMT]]></title><description><![CDATA[<p>Bei der Parameterübergabe solltest du besser noch die Anzahl als Parameter angeben, z.B. (..., int anzahl).<br />
Denn statt 'int array[10]' kann man auch einfach 'int array[]' als Parameter schreiben und ein beliebiges anderes Array übergeben. Dies wird vom Compiler nicht überprüft, denn intern ist ein Array bei der Parameterübergabe einfach ein Zeiger, d.h. 'int *array'.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1177791</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1177791</guid><dc:creator><![CDATA[Th]]></dc:creator><pubDate>Mon, 20 Nov 2006 14:05:07 GMT</pubDate></item></channel></rss>