<?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[Kommazahlen verhindern]]></title><description><![CDATA[<p>Hi<br />
gibt es die möglichkeit kommazahlen zu verhindern?<br />
d.h. wenn man beim &quot;cin&quot; eine kommazahl eingibt dann soll eine ferhlermeldung erscheinen?</p>
<p>Ich programmiere mit Dev-c++</p>
<p>grüße, jens</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/163584/kommazahlen-verhindern</link><generator>RSS for Node</generator><lastBuildDate>Sun, 13 Sep 2026 11:43:55 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/163584.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 31 Oct 2006 09:34:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Kommazahlen verhindern on Tue, 31 Oct 2006 09:34:17 GMT]]></title><description><![CDATA[<p>Hi<br />
gibt es die möglichkeit kommazahlen zu verhindern?<br />
d.h. wenn man beim &quot;cin&quot; eine kommazahl eingibt dann soll eine ferhlermeldung erscheinen?</p>
<p>Ich programmiere mit Dev-c++</p>
<p>grüße, jens</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1165138</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1165138</guid><dc:creator><![CDATA[theschaaf]]></dc:creator><pubDate>Tue, 31 Oct 2006 09:34:17 GMT</pubDate></item><item><title><![CDATA[Reply to Kommazahlen verhindern on Tue, 31 Oct 2006 09:47:28 GMT]]></title><description><![CDATA[<p>keine ahnung... aber du könntest die eingabe modulo 1 prüfen (iZahl%1).</p>
<p>quasi</p>
<pre><code class="language-cpp">if(iZahl%1 == 0)
   //Ganzzahl
else
   //Kommazahl
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1165146</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1165146</guid><dc:creator><![CDATA[DanielusITF]]></dc:creator><pubDate>Tue, 31 Oct 2006 09:47:28 GMT</pubDate></item><item><title><![CDATA[Reply to Kommazahlen verhindern on Tue, 31 Oct 2006 09:55:18 GMT]]></title><description><![CDATA[<p>hmm du könntest doch auch versuchen die zahl in eine integral var zu casten indem du nen (int) vorshcreibst oder nicht?<br />
also:</p>
<pre><code class="language-cpp">float zahl;
    cin &gt;&gt; zahl;
    cout &lt;&lt; (int)zahl &lt;&lt; endl;
</code></pre>
<p>vieleicht hilft das ja</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1165155</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1165155</guid><dc:creator><![CDATA[T0bi]]></dc:creator><pubDate>Tue, 31 Oct 2006 09:55:18 GMT</pubDate></item><item><title><![CDATA[Reply to Kommazahlen verhindern on Tue, 31 Oct 2006 09:57:26 GMT]]></title><description><![CDATA[<p>hi<br />
also es geht um dieses spielchen</p>
<pre><code class="language-cpp">#include &lt;iostream.h&gt;

using namespace std;

int main() {
  int versuch=0, zahl, tipp;

   cout&lt;&lt;&quot;...::: Ratespiel :::...\n\n&quot;;
  anfang:;
  cout&lt;&lt;&quot;Geben sie die zu Erratene Zahl ein: &quot;;
  cin&gt;&gt;zahl;  
  if (zahl &gt; 100){
  cout&lt;&lt;&quot;Die Zahl ist groesser als 100 bitte nochmal eingeben!\n\n&quot;;
  goto anfang;
  }  

  if(zahl%1 == 0){
            cout&lt;&lt;&quot;Eine Ganze Zahl&quot;;
            }            
   //Ganzzahl
  else  {
            cout&lt;&lt;&quot;Eine Komma-Zahl&quot;;
            }   
   //Kommazahl

  cout&lt;&lt;&quot;Nun duerfen sie Raten, geben sie Ihren Tipp ein: &quot;;
  tippeingabe:;
  cin&gt;&gt;tipp;

  if (tipp &gt; 100){
  cout&lt;&lt;&quot;Dumpfbacke, die Zahl ist nicht groesser als 100!\nIhr neuer Tipp: &quot;;
  goto tippeingabe;
  } 
  if (zahl == tipp){
  cout&lt;&lt;&quot;Richtig &quot;;
  versuch=versuch+1;
  goto ende;
  } 
  if (zahl &gt; tipp){
  cout&lt;&lt;&quot;Die Zahl ist leider zu niedrig, ihr neuer Versuch: &quot;;
  versuch=versuch+1;
  goto tippeingabe;
  }   
  if (zahl &lt; tipp){
  cout&lt;&lt;&quot;Die Zahl ist leider zu hoch, ihr neuer Versuch: &quot;;
  versuch=versuch+1;
  goto tippeingabe;
  }         

  ende:;
  cout&lt;&lt;&quot;Sie haben die Zahl beim &quot;&lt;&lt;versuch&lt;&lt;&quot;ten Versuch erraten\n\n&quot;;

  system(&quot;PAUSE&quot;);
  return 0;
}
</code></pre>
<p>ich probier mal eben weiter.</p>
<p>danke schomal für die antworten.<br />
theschaaf</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1165159</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1165159</guid><dc:creator><![CDATA[theschaaf]]></dc:creator><pubDate>Tue, 31 Oct 2006 09:57:26 GMT</pubDate></item><item><title><![CDATA[Reply to Kommazahlen verhindern on Tue, 31 Oct 2006 10:01:56 GMT]]></title><description><![CDATA[<p>wenn du</p>
<pre><code class="language-cpp">int zahl;
cin &gt;&gt; zahl;
</code></pre>
<p>machst, dann ist zahl immer ganzzahlig, egal was du eingegeben hast.</p>
<p>versuch doch ma</p>
<pre><code class="language-cpp">float zahl;
cin &gt;&gt; zahl;
if(zahl - floor(zahl) &gt; 0.0000001f)
cout &lt;&lt; &quot;Komazahl!&quot; &lt;&lt; endl;
else
cout &lt;&lt; &quot;ganze zahl&quot; &lt;&lt; endl;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1165165</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1165165</guid><dc:creator><![CDATA[Maxi]]></dc:creator><pubDate>Tue, 31 Oct 2006 10:01:56 GMT</pubDate></item><item><title><![CDATA[Reply to Kommazahlen verhindern on Tue, 31 Oct 2006 10:04:30 GMT]]></title><description><![CDATA[<p>was ist denn floor, welche funktion hat das?<br />
soll ich das nochma neu ähm &quot;deklarieren&quot;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1165167</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1165167</guid><dc:creator><![CDATA[theschaaf]]></dc:creator><pubDate>Tue, 31 Oct 2006 10:04:30 GMT</pubDate></item><item><title><![CDATA[Reply to Kommazahlen verhindern on Tue, 31 Oct 2006 10:09:20 GMT]]></title><description><![CDATA[<p>theschaaf schrieb:</p>
<blockquote>
<p>was ist denn floor, welche funktion hat das?<br />
soll ich das nochma neu ähm &quot;deklarieren&quot;</p>
</blockquote>
<p>steht in der MSDN.</p>
<p>mit der modulo lösung kannst du halt float verwenden und prüfen ob eine ganze oder eine kommazahl angegeben wurde. bei int kannst du dir die abfrage sparen, weil int eh keine kommastellen hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1165175</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1165175</guid><dc:creator><![CDATA[DanielusITF]]></dc:creator><pubDate>Tue, 31 Oct 2006 10:09:20 GMT</pubDate></item><item><title><![CDATA[Reply to Kommazahlen verhindern on Tue, 31 Oct 2006 10:25:00 GMT]]></title><description><![CDATA[<p>DanielusITF schrieb:</p>
<blockquote>
<p>mit der modulo lösung kannst du halt float verwenden und prüfen ob eine ganze oder eine kommazahl angegeben wurde.</p>
</blockquote>
<p>Was für einen tollen Compiler hast du denn, der Modulo mit Fließkommatypen erlaubt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1165188</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1165188</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Tue, 31 Oct 2006 10:25:00 GMT</pubDate></item><item><title><![CDATA[Reply to Kommazahlen verhindern on Tue, 31 Oct 2006 10:53:26 GMT]]></title><description><![CDATA[<p>MFK schrieb:</p>
<blockquote>
<p>DanielusITF schrieb:</p>
<blockquote>
<p>mit der modulo lösung kannst du halt float verwenden und prüfen ob eine ganze oder eine kommazahl angegeben wurde.</p>
</blockquote>
<p>Was für einen tollen Compiler hast du denn, der Modulo mit Fließkommatypen erlaubt?</p>
</blockquote>
<p>uff, das kommt davon wenn man es nicht vorher ausprobiert. bitte um entschuldigung. bin in c++ auch noch recht frisch. fand die lösung mit modulo irgendwie &quot;cool&quot; <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> naja, dann eben doch mit float in int casten <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/1165194</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1165194</guid><dc:creator><![CDATA[DanielusITF]]></dc:creator><pubDate>Tue, 31 Oct 2006 10:53:26 GMT</pubDate></item><item><title><![CDATA[Reply to Kommazahlen verhindern on Thu, 02 Nov 2006 10:58:41 GMT]]></title><description><![CDATA[<p>hey<br />
es funktioniert jetzt so</p>
<pre><code class="language-cpp">#include &lt;iostream.h&gt;

using namespace std;

int main() {
  float zahl;
  double versuch=0,  tipp, zahl2; 
  cout&lt;&lt;&quot;...::: Ratespiel :::...\n\n&quot;;
  anfang:;
  cout&lt;&lt;&quot;Geben sie die zu Erratene Zahl ein: &quot;;
  cin&gt;&gt;zahl;  

  if (zahl &gt; 100){
  cout&lt;&lt;&quot;Die Zahl ist groesser als 100 bitte nochmal eingeben!\n\n&quot;;
  goto anfang;
  }  

  if(zahl - floor(zahl) &gt; 0.0000001f) {
  cout &lt;&lt; &quot;Komazahl so gehts nicht!&quot; &lt;&lt; endl; 
  goto anfang;}

  tippeingabe:;
  cout&lt;&lt;&quot;\n\n\nNun duerfen sie Raten, geben sie Ihren Tipp ein: &quot;;

  cin&gt;&gt;tipp;

  if(tipp - floor(tipp) &gt; 0.0000001f) {
  cout &lt;&lt; &quot;Komazahl so gehts nicht!&quot; &lt;&lt; endl; 
  goto tippeingabe;}

  if (tipp &gt; 100){
  cout&lt;&lt;&quot;Dumpfbacke, die Zahl ist nicht groesser als 100!\nIhr neuer Tipp: &quot;;
  goto tippeingabe;
  }  

  if (zahl == tipp){
  cout&lt;&lt;&quot;Richtig &quot;;
  versuch=versuch+1;
  goto ende;
  } 
  if (zahl &gt; tipp){
  cout&lt;&lt;&quot;Die Zahl ist leider zu niedrig, ihr neuer Versuch: &quot;;
  versuch=versuch+1;
  goto tippeingabe;
  }   
  if (zahl &lt; tipp){
  cout&lt;&lt;&quot;Die Zahl ist leider zu hoch, ihr neuer Versuch: &quot;;
  versuch=versuch+1;
  goto tippeingabe;
  }         

  ende:;
  cout&lt;&lt;&quot;Sie haben die Zahl beim &quot;&lt;&lt;versuch&lt;&lt;&quot;ten Versuch erraten\n\n&quot;;

  system(&quot;PAUSE&quot;);
  return 0;
}
</code></pre>
<p>aber was genau macht denn floor? es funktioniert, aber ich weiss nicht so genau warum <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f4a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--light_bulb"
      title=":bulb:"
      alt="💡"
    /> .<br />
kann mir das vll jemand ein bisschen erklären?</p>
<p>grüße, theschaaf</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1166841</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1166841</guid><dc:creator><![CDATA[theschaaf]]></dc:creator><pubDate>Thu, 02 Nov 2006 10:58:41 GMT</pubDate></item><item><title><![CDATA[Reply to Kommazahlen verhindern on Thu, 02 Nov 2006 11:32:25 GMT]]></title><description><![CDATA[<p>*autsch* GoTo's</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1166864</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1166864</guid><dc:creator><![CDATA[aua]]></dc:creator><pubDate>Thu, 02 Nov 2006 11:32:25 GMT</pubDate></item><item><title><![CDATA[Reply to Kommazahlen verhindern on Thu, 02 Nov 2006 12:19:57 GMT]]></title><description><![CDATA[<p>#teer und federn bereitstell#</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1166900</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1166900</guid><dc:creator><![CDATA[EXDW]]></dc:creator><pubDate>Thu, 02 Nov 2006 12:19:57 GMT</pubDate></item></channel></rss>