C float decimal not being memorized -


इस सवाल का पहले से ही एक उत्तर है: < / P>

  • 5 जवाब

    मेरे पास कोड का एक टुकड़ा है ऐसा लगता है: <पूर्व> फ्लोट एनबी = 100/42; Printf ("% .2f", एनबी);

    जो मुझे 2.38 प्रिंट करने की अपेक्षा करता है, लेकिन इसके बजाय यह 2.00 प्रिंट करता है।

    42 सिर्फ एक उदाहरण है मूल कोड में यह एक चर है।

    आपको नंबरों को फ़्लोटिंग पॉइंट स्वयं के रूप में निर्दिष्ट करने की आवश्यकता है। इसे आज़माएं: <पूर्व> #include & lt; stdio.h & gt; # शामिल करें & lt; stdlib.h & gt; Int main (int argc, char ** argv) {float nb = 100.0 / 42.0; Printf ("% .2f \ n", एनबी); वापसी 0; }

Comments

Popular posts from this blog

php - how to change mysql_result($res, 0, "url"); to mysqli -

c# - How to clone a HttpRequestMessage when the original request has Content? -

split - php explode string with Uppercase if lowercase letter exists before it without space -