<?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[Moduloberechnung mit int möglich aber nicht mit double und float?]]></title><description><![CDATA[<pre><code class="language-cpp">//
#include &lt;iostream&gt;
using namespace std;
int main()
{
	float hW,bW,fW,hF,bF,fF,anzahl; //noetige Variablen
	char auswahl;

	cout &lt;&lt; &quot;Fliesen berechnen (F)&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;Tapetenrollen berechnen (T)&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;Farbverbrauch berechnen (C)&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;Waehlen Sie F,T oder C:&quot; &lt;&lt; endl;
	cin &gt;&gt; auswahl;

	switch(auswahl)
	{
case 'F':
case 'f':
auswahl = 'F';
	cout &lt;&lt; &quot;Geben Sie die Hoehe der Wand in CM ein:&quot; &lt;&lt; endl; //Eingabe der noetigen Variablen
	cin &gt;&gt; hW;
	cout &lt;&lt; &quot;Geben Sie die Breite der Wand in CM ein:&quot; &lt;&lt; endl;
	cin &gt;&gt; bW;
	cout &lt;&lt; &quot;Geben Sie die Hoehe der Fliese in CM ein:&quot; &lt;&lt; endl;
	cin &gt;&gt; hF;
	cout &lt;&lt; &quot;Geben Sie die Breite der Fliese in CM ein:&quot; &lt;&lt; endl;
	cin &gt;&gt; bF;

	fF = hF * bF; // Berechnung der Ausgabe
	fW = hW * bW;
	anzahl = fW / fF;

	if(anzahl%2!=0) //Abfrage, ob Abfall uebrig bleibt
	{
	cout &lt;&lt; &quot;Sie benoetigen &quot; &lt;&lt; anzahl &lt;&lt; &quot; Fliesen um die Wand zu fliesen.&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;Es bleibt Abfall uebrig.&quot; &lt;&lt; endl;
	}

	if(anzahl%2==0) //Abfrage, ob Abfall uebrig bleibt
	{
	cout &lt;&lt; &quot;Sie benoetigen &quot; &lt;&lt; anzahl &lt;&lt; &quot; Fliesen um die Wand zu fliesen.&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;Es bleibt kein Abfall uebrig.&quot; &lt;&lt; endl;
	}

break;

case 'T':
case 't':
auswahl = 'T';
cout &lt;&lt; &quot;Sie haben Menuepunkt &quot; &lt;&lt; auswahl &lt;&lt; &quot; gewaehlt.&quot; &lt;&lt; endl &lt;&lt; endl;
break;

case 'C':
case 'c': 
auswahl = 'C';
cout &lt;&lt; &quot;Sie haben Menuepunkt &quot; &lt;&lt; auswahl &lt;&lt; &quot; gewaehlt.&quot; &lt;&lt; endl &lt;&lt; endl;
break;

default : cout &lt;&lt; &quot;Sie haben keinen Menuepunkt gewaehlt&quot;&lt;&lt; endl;
	}

	return 0;
}
</code></pre>
<p>wenn ich float oder double durch int ersetzte läuft das programm.<br />
mit float und double spuckt er folgende fehlermeldung aus.</p>
<p>error C2296: '%': Ungültig, da der linke Operand vom Typ 'float' ist</p>
<p>liegt das daran, das es einfach keinen restwert gibt bei kommazahlen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/297296/moduloberechnung-mit-int-möglich-aber-nicht-mit-double-und-float</link><generator>RSS for Node</generator><lastBuildDate>Fri, 14 Aug 2026 11:56:01 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/297296.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 23 Dec 2011 13:17:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Moduloberechnung mit int möglich aber nicht mit double und float? on Fri, 23 Dec 2011 13:18:39 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">//
#include &lt;iostream&gt;
using namespace std;
int main()
{
	float hW,bW,fW,hF,bF,fF,anzahl; //noetige Variablen
	char auswahl;

	cout &lt;&lt; &quot;Fliesen berechnen (F)&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;Tapetenrollen berechnen (T)&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;Farbverbrauch berechnen (C)&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;Waehlen Sie F,T oder C:&quot; &lt;&lt; endl;
	cin &gt;&gt; auswahl;

	switch(auswahl)
	{
case 'F':
case 'f':
auswahl = 'F';
	cout &lt;&lt; &quot;Geben Sie die Hoehe der Wand in CM ein:&quot; &lt;&lt; endl; //Eingabe der noetigen Variablen
	cin &gt;&gt; hW;
	cout &lt;&lt; &quot;Geben Sie die Breite der Wand in CM ein:&quot; &lt;&lt; endl;
	cin &gt;&gt; bW;
	cout &lt;&lt; &quot;Geben Sie die Hoehe der Fliese in CM ein:&quot; &lt;&lt; endl;
	cin &gt;&gt; hF;
	cout &lt;&lt; &quot;Geben Sie die Breite der Fliese in CM ein:&quot; &lt;&lt; endl;
	cin &gt;&gt; bF;

	fF = hF * bF; // Berechnung der Ausgabe
	fW = hW * bW;
	anzahl = fW / fF;

	if(anzahl%2!=0) //Abfrage, ob Abfall uebrig bleibt
	{
	cout &lt;&lt; &quot;Sie benoetigen &quot; &lt;&lt; anzahl &lt;&lt; &quot; Fliesen um die Wand zu fliesen.&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;Es bleibt Abfall uebrig.&quot; &lt;&lt; endl;
	}

	if(anzahl%2==0) //Abfrage, ob Abfall uebrig bleibt
	{
	cout &lt;&lt; &quot;Sie benoetigen &quot; &lt;&lt; anzahl &lt;&lt; &quot; Fliesen um die Wand zu fliesen.&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;Es bleibt kein Abfall uebrig.&quot; &lt;&lt; endl;
	}

break;

case 'T':
case 't':
auswahl = 'T';
cout &lt;&lt; &quot;Sie haben Menuepunkt &quot; &lt;&lt; auswahl &lt;&lt; &quot; gewaehlt.&quot; &lt;&lt; endl &lt;&lt; endl;
break;

case 'C':
case 'c': 
auswahl = 'C';
cout &lt;&lt; &quot;Sie haben Menuepunkt &quot; &lt;&lt; auswahl &lt;&lt; &quot; gewaehlt.&quot; &lt;&lt; endl &lt;&lt; endl;
break;

default : cout &lt;&lt; &quot;Sie haben keinen Menuepunkt gewaehlt&quot;&lt;&lt; endl;
	}

	return 0;
}
</code></pre>
<p>wenn ich float oder double durch int ersetzte läuft das programm.<br />
mit float und double spuckt er folgende fehlermeldung aus.</p>
<p>error C2296: '%': Ungültig, da der linke Operand vom Typ 'float' ist</p>
<p>liegt das daran, das es einfach keinen restwert gibt bei kommazahlen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2160424</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2160424</guid><dc:creator><![CDATA[Awebb]]></dc:creator><pubDate>Fri, 23 Dec 2011 13:18:39 GMT</pubDate></item><item><title><![CDATA[Reply to Moduloberechnung mit int möglich aber nicht mit double und float? on Fri, 23 Dec 2011 13:28:12 GMT]]></title><description><![CDATA[<p>Du suchst fmod.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2160430</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2160430</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 23 Dec 2011 13:28:12 GMT</pubDate></item><item><title><![CDATA[Reply to Moduloberechnung mit int möglich aber nicht mit double und float? on Fri, 23 Dec 2011 13:29:30 GMT]]></title><description><![CDATA[<p>In math.h/cmath gibt es die Funktion <a href="http://www.cplusplus.com/reference/clibrary/cmath/fmod" rel="nofollow">fmod</a></p>
<p>Edit: War ja klar...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2160431</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2160431</guid><dc:creator><![CDATA[aVoX]]></dc:creator><pubDate>Fri, 23 Dec 2011 13:29:30 GMT</pubDate></item><item><title><![CDATA[Reply to Moduloberechnung mit int möglich aber nicht mit double und float? on Fri, 23 Dec 2011 13:37:47 GMT]]></title><description><![CDATA[<p>Vielen Dank Jungs. Ist echt nen hammer Forum hier :xmas1:</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2160434</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2160434</guid><dc:creator><![CDATA[Awebb]]></dc:creator><pubDate>Fri, 23 Dec 2011 13:37:47 GMT</pubDate></item></channel></rss>