Temperature Converter - Problem

Create a program that converts temperatures between Celsius and Fahrenheit scales.

Given a temperature in Celsius, calculate and display both:

  • The equivalent temperature in Fahrenheit
  • The original temperature in Celsius for verification

Use the formula: Fahrenheit = (Celsius × 9/5) + 32

Input: A floating-point number representing temperature in Celsius

Output: Two floating-point numbers - first the Fahrenheit equivalent, then the original Celsius value

Input & Output

Example 1 — Room Temperature
$ Input: celsius = 25.0
Output: 77.0 25.0
💡 Note: Room temperature 25°C converts to 77°F using F = (25 × 9/5) + 32 = 77
Example 2 — Freezing Point
$ Input: celsius = 0.0
Output: 32.0 0.0
💡 Note: Water freezing point 0°C converts to 32°F using F = (0 × 9/5) + 32 = 32
Example 3 — Negative Temperature
$ Input: celsius = -10.0
Output: 14.0 -10.0
💡 Note: Cold temperature -10°C converts to 14°F using F = (-10 × 9/5) + 32 = 14

Constraints

  • -273.15 ≤ celsius ≤ 1000.0
  • Temperature must be above absolute zero

Visualization

Tap to expand
INPUTALGORITHMRESULTTemperature25.0°CCelsius Input1Read Celsius value2Apply formula:F = (C × 9/5) + 323Calculate result:F = (25 × 1.8) + 32 = 774Return both valuesOutput77.0 25.0Fahrenheit + CelsiusKey Insight:Temperature conversion uses a linear mathematical formula that maintainsproportional relationships between the two scales.TutorialsPoint - Temperature Converter | Mathematical Formula
Asked in
Google 15 Amazon 12 Microsoft 10
15.2K Views
Medium Frequency
~5 min Avg. Time
420 Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen