समस्या
Convert a temperature in degrees Celsius to degrees Fahrenheit using F = C × 9 / 5 + 32.
Implement celsius_to_fahrenheit(celsius).
Input
celsius: The temperature in degrees Celsius.
Output
Return the temperature in degrees Fahrenheit (a decimal number).
सीमाएँ
-273.15 ≤ celsius ≤ 10,000
उदाहरण
इनपुट:
celsius = 100.0
अपेक्षित आउटपुट:
expected = 212.0
इनपुट:
double celsius = 100.0;
अपेक्षित आउटपुट:
double expected = 212.0;
इनपुट:
double celsius = 100.0;
अपेक्षित आउटपुट:
double expected = 212.0;
व्याख्या
100 × 9 / 5 + 32 = 212, the boiling point of water.
इनपुट:
celsius = -40.0
अपेक्षित आउटपुट:
expected = -40.0
इनपुट:
double celsius = -40.0;
अपेक्षित आउटपुट:
double expected = -40.0;
इनपुट:
double celsius = -40.0;
अपेक्षित आउटपुट:
double expected = -40.0;
व्याख्या
-40 × 9 / 5 + 32 = -40: both scales meet at -40.
कैसे हल करें
पहले खुद कोशिश करें, फिर एक-एक करके संकेत खोलें।
संकेत 1
यह एक direct unit conversion है, एक linear scale से दूसरी पर.
संकेत 2
दिया गया formula ध्यान से apply करो, खासकर multiplication और division का order.
संकेत 3
Result को decimal value ही रखो, क्योंकि कई inputs exact integers में convert नहीं होते.
अपेक्षित जटिलता
समय O(1), अतिरिक्त स्थान O(1)
संदर्भ
यह चुनौती CodeUtility के लिए अनुकूलित की गई है। ऊपर दिए गए स्टेटमेंट और सीमाओं का पालन करें।