Programming Challenge: Temperature Conversion (Easy)

Description

Write a program to convert a temperature from Fahrenheit to Celsius. The formula to convert Fahrenheit to Celsius is:

where ( C ) is the temperature in Celsius and ( F ) is the temperature in Fahrenheit.

Input

A single integer, ( F ), the temperature in Fahrenheit.

Output

Print the temperature in Celsius rounded to the nearest integer.

Sample Input:

68

Sample Output:

20

Explanation

Converting 68 degrees Fahrenheit to Celsius:

Hence, the output is 20 degrees Celsius.

Constraints

  • -100 \leq F \leq 100

Test Cases

InputOutput
320
212100
-40-40
0-18

Programming Concepts Addressed

  1. Arithmetic Operations: The core of this problem involves the correct application of arithmetic operations—subtraction, multiplication, and division—to transform the input temperature.
  2. Data Type Conversion: Conversion from a floating-point number (the result of the division) to an integer (rounded result) is crucial.
  3. Conditional Logic: Implementing the rounding logic requires understanding how to round a number correctly based on its fractional part.
  4. Input/Output Operations: Reading from standard input and printing to standard output are basic yet essential programming skills.

Summary

This challenge tests basic understanding of arithmetic operations, data type conversion, and conditional logic, making it suitable for beginner-level programmers. The problem also introduces handling of standard input and output, which is fundamental in programming contests.


This challenge was written with the help of ChatGPT. If you see any errors I would appreciate if you let me know via the comments below. Thanks!

Leave a Reply