<?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[Brauche Hilfe, der Code funktioniert nicht !!!]]></title><description><![CDATA[<p>Hallo an alle, schon ein paar Tage versuche ich dieses kleines Programm zum laufen zu bringen und kriege das nicht auf die Reihe, das Programm soll durch die ABC-Formel die Lösung zu einer quadratische Gleichung liefern, dabei ist zu beachten, das nicht für alle Gleichungen eine reelle Lösung gibt. Könnt ihr mir helfen?, wäre sehr dankbar. Wo ist der Fehler, das immer nur blödsinn ausgegeben wird, wie kann man das besser machen, Danke im vorraus <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="🙂"
    /> . Hier der Code.</p>
<p>/* Aufgabe zur Lösung von quadratischen Gleichungen */<br />
/* Formel x1/2 = (-b) +- wurzel(b² - 4ac) / 2a */</p>
<p>#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;math.h&gt;</p>
<p>void funktion(const double a, const double b, const double c, double *x1, double *x2);</p>
<p>main()<br />
{<br />
double a, b, c, x1, x2;</p>
<p>printf(&quot;Geben Sie &quot;&quot;a&quot;&quot; ein: &quot;);<br />
scanf(&quot;%f&quot;, &amp;a);<br />
printf(&quot;Geben Sie &quot;&quot;b&quot;&quot; ein: &quot;);<br />
scanf(&quot;%f&quot;, &amp;b);<br />
printf(&quot;Geben Sie &quot;&quot;c&quot;&quot; ein: &quot;);<br />
scanf(&quot;%f&quot;, &amp;c);</p>
<p>funktion(a, b, c, &amp;x1, &amp;x2);</p>
<p>if(x1 != x2)<br />
{<br />
printf(&quot;X1 = %0.3f\n&quot;, x1);<br />
printf(&quot;X2 = %0.3f\n&quot;, x2);<br />
}<br />
else if(x1 == x2)<br />
{<br />
printf(&quot;Doppelte Stelle bei %0.3f.\n&quot;, x1);<br />
}<br />
return 0;<br />
}</p>
<p>void funktion(const double a, const double b, const double c, double *x1, double *x2)<br />
{<br />
double det = (pow(b,2) - (4*a*c));<br />
double wurzel = sqrt(det);</p>
<p>if(det != 0 &amp;&amp; det &gt; 0)<br />
{<br />
*x1 = (-b + wurzel) / (2*a);<br />
*x1 = (-b - wurzel) / (2*a);<br />
}<br />
else if(det == 0)<br />
{<br />
*x1 = (-b + wurzel) / (2*a);<br />
*x1 = (-b - wurzel) / (2*a);<br />
}<br />
else if( det != 0 &amp;&amp; det &lt; 0)<br />
{<br />
printf(&quot;Keine reelle Lösung.\n&quot;);<br />
}<br />
}</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/199873/brauche-hilfe-der-code-funktioniert-nicht</link><generator>RSS for Node</generator><lastBuildDate>Sat, 03 Oct 2026 21:19:22 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/199873.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 07 Dec 2007 22:02:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Brauche Hilfe, der Code funktioniert nicht !!! on Fri, 07 Dec 2007 22:02:42 GMT]]></title><description><![CDATA[<p>Hallo an alle, schon ein paar Tage versuche ich dieses kleines Programm zum laufen zu bringen und kriege das nicht auf die Reihe, das Programm soll durch die ABC-Formel die Lösung zu einer quadratische Gleichung liefern, dabei ist zu beachten, das nicht für alle Gleichungen eine reelle Lösung gibt. Könnt ihr mir helfen?, wäre sehr dankbar. Wo ist der Fehler, das immer nur blödsinn ausgegeben wird, wie kann man das besser machen, Danke im vorraus <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="🙂"
    /> . Hier der Code.</p>
<p>/* Aufgabe zur Lösung von quadratischen Gleichungen */<br />
/* Formel x1/2 = (-b) +- wurzel(b² - 4ac) / 2a */</p>
<p>#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;math.h&gt;</p>
<p>void funktion(const double a, const double b, const double c, double *x1, double *x2);</p>
<p>main()<br />
{<br />
double a, b, c, x1, x2;</p>
<p>printf(&quot;Geben Sie &quot;&quot;a&quot;&quot; ein: &quot;);<br />
scanf(&quot;%f&quot;, &amp;a);<br />
printf(&quot;Geben Sie &quot;&quot;b&quot;&quot; ein: &quot;);<br />
scanf(&quot;%f&quot;, &amp;b);<br />
printf(&quot;Geben Sie &quot;&quot;c&quot;&quot; ein: &quot;);<br />
scanf(&quot;%f&quot;, &amp;c);</p>
<p>funktion(a, b, c, &amp;x1, &amp;x2);</p>
<p>if(x1 != x2)<br />
{<br />
printf(&quot;X1 = %0.3f\n&quot;, x1);<br />
printf(&quot;X2 = %0.3f\n&quot;, x2);<br />
}<br />
else if(x1 == x2)<br />
{<br />
printf(&quot;Doppelte Stelle bei %0.3f.\n&quot;, x1);<br />
}<br />
return 0;<br />
}</p>
<p>void funktion(const double a, const double b, const double c, double *x1, double *x2)<br />
{<br />
double det = (pow(b,2) - (4*a*c));<br />
double wurzel = sqrt(det);</p>
<p>if(det != 0 &amp;&amp; det &gt; 0)<br />
{<br />
*x1 = (-b + wurzel) / (2*a);<br />
*x1 = (-b - wurzel) / (2*a);<br />
}<br />
else if(det == 0)<br />
{<br />
*x1 = (-b + wurzel) / (2*a);<br />
*x1 = (-b - wurzel) / (2*a);<br />
}<br />
else if( det != 0 &amp;&amp; det &lt; 0)<br />
{<br />
printf(&quot;Keine reelle Lösung.\n&quot;);<br />
}<br />
}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1416800</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1416800</guid><dc:creator><![CDATA[el_latin]]></dc:creator><pubDate>Fri, 07 Dec 2007 22:02:42 GMT</pubDate></item><item><title><![CDATA[Reply to Brauche Hilfe, der Code funktioniert nicht !!! on Fri, 07 Dec 2007 22:35:35 GMT]]></title><description><![CDATA[<p>1. Es gibt hier Codetags</p>
<pre><code class="language-cpp">void funktion(const double a, const double b, const double c, double *x1,  double *x2)
{
	double det = (pow(b,2) - (4*a*c));
	double wurzel = sqrt(det);

	if(det != 0 &amp;&amp; det &gt; 0)
	{
		*x1 = (-b + wurzel) / (2*a);
		*x1 = (-b - wurzel) / (2*a);
	}
	else if(det == 0)
	{
		*x1 = (-b + wurzel) / (2*a);
		*x1 = (-b - wurzel) / (2*a);
	}
	else if( det != 0 &amp;&amp; det &lt; 0)
	{ 
		printf(&quot;Keine reelle Lösung.\n&quot;);
	}
}
</code></pre>
<p>2. Debugger gibt es auch (nicht hier, aber im allgemeinen)<br />
3. Du hast immer nur x1 =... da stehen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1416817</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1416817</guid><dc:creator><![CDATA[karrrrqa]]></dc:creator><pubDate>Fri, 07 Dec 2007 22:35:35 GMT</pubDate></item><item><title><![CDATA[Reply to Brauche Hilfe, der Code funktioniert nicht !!! on Fri, 07 Dec 2007 22:38:28 GMT]]></title><description><![CDATA[<p>Das Problem liegt darin, dass bei scanf(&quot;%f&quot;, &amp;double-Wert) nur Mist im double steht. Ändere die Variablen a,b und c vom Typ nach float.<br />
Außerdem gibt es noch einen copy&amp;paste-Fehler bei der Berechnung von x2.</p>
<pre><code class="language-cpp">if(det != 0 &amp;&amp; det &gt; 0)
{
    *x1 = (-b + wurzel) / (2*a);
    *x1 = (-b - wurzel) / (2*a);  // *x2
}
else if(det == 0)
{
    *x1 = (-b + wurzel) / (2*a);
    *x1 = (-b - wurzel) / (2*a);  // *x2
}
else ...
</code></pre>
<p>Das ganze ist C-Code und das <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-10.html" rel="nofollow">C-Forum ist hier</a>.</p>
<p>:xmas2: Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1416820</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1416820</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Fri, 07 Dec 2007 22:38:28 GMT</pubDate></item><item><title><![CDATA[Reply to Brauche Hilfe, der Code funktioniert nicht !!! on Sun, 09 Dec 2007 00:53:28 GMT]]></title><description><![CDATA[<p>Vielen Dank für die Schnelle Antwort, ihr hab recht gehabt, vielen dank !!! <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="🙂"
    /> :xmas1:</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1417380</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1417380</guid><dc:creator><![CDATA[el_latin]]></dc:creator><pubDate>Sun, 09 Dec 2007 00:53:28 GMT</pubDate></item></channel></rss>