<?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[Fehler bei Potenzierung&#x2F;Deklaration von Variablen??]]></title><description><![CDATA[<p>Hi leute,<br />
also ich bin in c++ Neuling und habe jetzt ein Code geschreiben, bei dem ich ein Fehler habe, der womöglich recht einfach zu beheben ist.<br />
Die Struktur des Quellcodes ist dabei soweit in Ordnung, Vereinachungen sind erstmal nicht notwendig, da ich dabei nur so vorgegangen bin, wie ich mit meinem momentanen Wissenstand aus der Vorlesung dazu in der Lage war.<br />
Der Fehler liegt hierbei ganz einfach in der mathematischen Potenzierung<br />
bestimmter Variablen oder habe ich die Variablen vielleicht doch falsch deklariert? Die Fehler liegen in dem von mir fett markierten Bereich, den Rest des Codes habe ich aus einer Aufgabe, die ich zuvor schon korrekt absolviert hatte.<br />
Ich weiß, dass der Fehler vielleicht zu simpel ist, hoffe trotzdem auf einen richtigen Hinweis.<br />
Besten Dank boenz</p>
<pre><code>#include &lt;stdio.h&gt;
#include &lt;math.h&gt;

int main ()
{
    float x,y,z;
    float a,b,c;
    int i,j;

    i = 2;
    j = 3;
    x = 3.4;
    y = 4.4;
    z = -3.6;

    [b]a = ((x^j)+(y^i))*z-1/(((x^i)-(y^j))*z);[/b]
    [b]b = (a^j)*((z^i)-(x^j));[/b]
    c = a*b;

    printf(&quot;Wir loesen folgende Gleichungen:\n\n&quot;);
    printf(&quot;a = (x^j+y^i)*z-1/((x^i-y^j)*z)\n&quot;);
    printf(&quot;b = a^j*(z^i-x^j)\n&quot;);
    printf(&quot;c = a*b\n\n&quot;);
    printf(&quot;Mit den gegeben Variablen:\n\n&quot;);
    printf(&quot;i = 2\n&quot;);
    printf(&quot;j = 3\n&quot;);
    printf(&quot;x = 3.4\n&quot;);
    printf(&quot;y = 4.4\n&quot;);
    printf(&quot;z = -3.6\n\n&quot;);
    printf(&quot;Die Loesung von a lautet: &quot;);
    printf(&quot;%f\n&quot;,a);
    printf(&quot;Die Loesung von b lautet: &quot;);
    printf(&quot;%f\n&quot;,b);
    printf(&quot;Die Loesung von c lautet: &quot;);
    printf(&quot;%f\n&quot;,c);

    getchar();
    return(0);

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/209533/fehler-bei-potenzierung-deklaration-von-variablen</link><generator>RSS for Node</generator><lastBuildDate>Mon, 12 Oct 2026 16:53:42 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/209533.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 31 Mar 2008 18:52:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fehler bei Potenzierung&#x2F;Deklaration von Variablen?? on Mon, 31 Mar 2008 18:52:10 GMT]]></title><description><![CDATA[<p>Hi leute,<br />
also ich bin in c++ Neuling und habe jetzt ein Code geschreiben, bei dem ich ein Fehler habe, der womöglich recht einfach zu beheben ist.<br />
Die Struktur des Quellcodes ist dabei soweit in Ordnung, Vereinachungen sind erstmal nicht notwendig, da ich dabei nur so vorgegangen bin, wie ich mit meinem momentanen Wissenstand aus der Vorlesung dazu in der Lage war.<br />
Der Fehler liegt hierbei ganz einfach in der mathematischen Potenzierung<br />
bestimmter Variablen oder habe ich die Variablen vielleicht doch falsch deklariert? Die Fehler liegen in dem von mir fett markierten Bereich, den Rest des Codes habe ich aus einer Aufgabe, die ich zuvor schon korrekt absolviert hatte.<br />
Ich weiß, dass der Fehler vielleicht zu simpel ist, hoffe trotzdem auf einen richtigen Hinweis.<br />
Besten Dank boenz</p>
<pre><code>#include &lt;stdio.h&gt;
#include &lt;math.h&gt;

int main ()
{
    float x,y,z;
    float a,b,c;
    int i,j;

    i = 2;
    j = 3;
    x = 3.4;
    y = 4.4;
    z = -3.6;

    [b]a = ((x^j)+(y^i))*z-1/(((x^i)-(y^j))*z);[/b]
    [b]b = (a^j)*((z^i)-(x^j));[/b]
    c = a*b;

    printf(&quot;Wir loesen folgende Gleichungen:\n\n&quot;);
    printf(&quot;a = (x^j+y^i)*z-1/((x^i-y^j)*z)\n&quot;);
    printf(&quot;b = a^j*(z^i-x^j)\n&quot;);
    printf(&quot;c = a*b\n\n&quot;);
    printf(&quot;Mit den gegeben Variablen:\n\n&quot;);
    printf(&quot;i = 2\n&quot;);
    printf(&quot;j = 3\n&quot;);
    printf(&quot;x = 3.4\n&quot;);
    printf(&quot;y = 4.4\n&quot;);
    printf(&quot;z = -3.6\n\n&quot;);
    printf(&quot;Die Loesung von a lautet: &quot;);
    printf(&quot;%f\n&quot;,a);
    printf(&quot;Die Loesung von b lautet: &quot;);
    printf(&quot;%f\n&quot;,b);
    printf(&quot;Die Loesung von c lautet: &quot;);
    printf(&quot;%f\n&quot;,c);

    getchar();
    return(0);

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1483991</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1483991</guid><dc:creator><![CDATA[boenz666]]></dc:creator><pubDate>Mon, 31 Mar 2008 18:52:10 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler bei Potenzierung&#x2F;Deklaration von Variablen?? on Mon, 31 Mar 2008 18:55:39 GMT]]></title><description><![CDATA[<p>^ ist wenn ich mich recht erinnere ein Bitweise-XOR, und nicht einfach die Potenz.</p>
<p>Um potenzen zu errehnen gibt es std::pow aus &lt;cmath&gt;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1483993</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1483993</guid><dc:creator><![CDATA[The-Kenny]]></dc:creator><pubDate>Mon, 31 Mar 2008 18:55:39 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler bei Potenzierung&#x2F;Deklaration von Variablen?? on Mon, 31 Mar 2008 19:22:07 GMT]]></title><description><![CDATA[<p>Ok, danke, das Ergebnis der ersten Gleichung habe ich jetzt schonmal richtig, Quellcode sieht nun wie folgt aus:</p>
<pre><code>#include &lt;stdio.h&gt;
#include &lt;math.h&gt;

int main ()
{
    float x,y,z;
    float a,b,c;
    double i,j,x1,x2,y1,y2,z1,a1;

    i = 2;
    j = 3;
    x = 3.4;
    y = 4.4;
    z = -3.6;
    x1 = pow(x,i);
    x2 = pow(x,j);
    y1 = pow(y,i);
    y2 = pow(y,j);
    z1 = pow(z,i);
    a1 = pow(a,j);

    a = (x2+y1)*z-1/((x1-y1)*z);
    b = a1*(z1-x2);
    c = a*b;

    printf(&quot;Wir loesen folgende Gleichungen:\n\n&quot;);
    printf(&quot;a = (x^j+y^i)*z-1/((x^i-y^j)*z)\n&quot;);
    printf(&quot;b = a^j*(z^i-x^j)\n&quot;);
    printf(&quot;c = a*b\n\n&quot;);
    printf(&quot;Mit den gegeben Variablen:\n\n&quot;);
    printf(&quot;i = 2\n&quot;);
    printf(&quot;j = 3\n&quot;);
    printf(&quot;x = 3.4\n&quot;);
    printf(&quot;y = 4.4\n&quot;);
    printf(&quot;z = -3.6\n\n&quot;);
    printf(&quot;Die Loesung von a lautet: &quot;);
    printf(&quot;%f\n&quot;,a);
    printf(&quot;Die Loesung von b lautet: &quot;);
    printf(&quot;%f\n&quot;,b);
    printf(&quot;Die Loesung von c lautet: &quot;);
    printf(&quot;%f\n&quot;,c);

    getchar();
    return(0);

}
</code></pre>
<p>Das Ergebnis der anderen beiden Gleichungen sieht allerdings sehr merkwürdig aus: -1.#INF00, sowie die positive Form dessen für Aufgabe 3.<br />
Einen Fehler in den Formeln habe ich nicht gefunden, kann das wieder mit der deklaration zutun haben?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1484007</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1484007</guid><dc:creator><![CDATA[boenz666]]></dc:creator><pubDate>Mon, 31 Mar 2008 19:22:07 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler bei Potenzierung&#x2F;Deklaration von Variablen?? on Mon, 31 Mar 2008 19:26:58 GMT]]></title><description><![CDATA[<p>Zu dem Zeitpunkt, zu dem du a1 aus a berechnest, ist a noch uninitialisiert. Du musst die Reihenfolge dieser Anweisungen vertauschen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1484009</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1484009</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Mon, 31 Mar 2008 19:26:58 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler bei Potenzierung&#x2F;Deklaration von Variablen?? on Mon, 31 Mar 2008 19:32:07 GMT]]></title><description><![CDATA[<p>Einfach so:</p>
<pre><code>b = a1*(z1-x2);
a = (x2+y1)*z-1/((x1-y1)*z);
</code></pre>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /><br />
Fehler bleibt dann aber.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1484013</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1484013</guid><dc:creator><![CDATA[boenz666]]></dc:creator><pubDate>Mon, 31 Mar 2008 19:32:07 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler bei Potenzierung&#x2F;Deklaration von Variablen?? on Mon, 31 Mar 2008 19:52:45 GMT]]></title><description><![CDATA[<p>Ne, er meint hier:</p>
<pre><code class="language-cpp">i = 2;
    j = 3;
    x = 3.4;
    y = 4.4;
    z = -3.6;
    x1 = pow(x,i);
    x2 = pow(x,j);
    y1 = pow(y,i);
    y2 = pow(y,j);
    z1 = pow(z,i);
    a1 = pow(a,j); // Hier wird a benutzt, aber 

    a = (x2+y1)*z-1/((x1-y1)*z); // hier wird es definiert..
    b = a1*(z1-x2);
    c = a*b;
</code></pre>
<p>also einfach:</p>
<pre><code class="language-cpp">..
a = (x2+y1)*z-1/((x1-y1)*z); 
a1 = pow(a,j); 
...
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1484027</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1484027</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Mon, 31 Mar 2008 19:52:45 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler bei Potenzierung&#x2F;Deklaration von Variablen?? on Mon, 31 Mar 2008 19:56:14 GMT]]></title><description><![CDATA[<p>Ach wie dumm, ist ja auch logisch, alles klar. Vielen Dank euch allen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1484034</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1484034</guid><dc:creator><![CDATA[boenz666]]></dc:creator><pubDate>Mon, 31 Mar 2008 19:56:14 GMT</pubDate></item></channel></rss>