Program to Convert From Celsius to Fahrenheit
- Write a program to Convert From Celsius to Fahrenheit in C
- Write a program to Convert From Celsius to Fahrenheit in C++
- Write a program to Convert From Celsius to Fahrenheit in Python
- Write a program to Convert From Celsius to Fahrenheit in PHP
- Write a program to Convert From Celsius to Fahrenheit in Java
- Write a program to Convert From Celsius to Fahrenheit in Java Script
- Write a program to Convert From Celsius to Fahrenheit in C#
Explanation:
The following formula can be used to convert a temperature from Celsius (°C) to Fahrenheit (°F):
Fahrenheit = (Celsius × 59) + 32
Steps to Convert
- Take the input temperature in Celsius (C).
- Multiply C by 9/5 (or 1.8).
- Add 32 to the result.
- The result is the temperature in Fahrenheit (F).
Program to Convert From Celsius to Fahrenheit
-
C
-
C++
-
Python
-
PHP
-
JAVA
-
Java Script
-
C#
#include <stdio.h> int main() { float celsius, fahrenheit; // Input Celsius value printf("Enter temperature in Celsius: "); scanf("%f", &celsius); // Convert to Fahrenheit fahrenheit = (celsius * 9 / 5) + 32; // Output the result printf("Temperature in Fahrenheit: %.2f\n", fahrenheit); return 0; }
#include <iostream> using namespace std; int main() { float celsius, fahrenheit; // Input Celsius value cout << "Enter temperature in Celsius: "; cin >> celsius; // Convert to Fahrenheit fahrenheit = (celsius * 9 / 5) + 32; // Output the result cout << "Temperature in Fahrenheit: " << fahrenheit << endl; return 0; }
celsius = float(input("Enter temperature in Celsius: ")) # Convert to Fahrenheit fahrenheit = (celsius * 9 / 5) + 32 # Output the result print(f"Temperature in Fahrenheit: {fahrenheit:.2f}")
<?php // Input Celsius value $celsius = (float)readline("Enter temperature in Celsius: "); // Convert to Fahrenheit $fahrenheit = ($celsius * 9 / 5) + 32; // Output the result echo "Temperature in Fahrenheit: " . number_format($fahrenheit, 2) . "\n"; ?>
import java.util.Scanner; public class CelsiusToFahrenheit { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); // Input Celsius value System.out.print("Enter temperature in Celsius: "); double celsius = scanner.nextDouble(); // Convert to Fahrenheit double fahrenheit = (celsius * 9 / 5) + 32; // Output the result System.out.printf("Temperature in Fahrenheit: %.2f\n", fahrenheit); scanner.close(); } }
let celsius = parseFloat(prompt("Enter temperature in Celsius: ")); // Convert to Fahrenheit let fahrenheit = (celsius * 9 / 5) + 32; // Output the result console.log(`Temperature in Fahrenheit: ${fahrenheit.toFixed(2)}`);
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950"><div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-csharp">using System; class Program { static void Main() { // Input Celsius value Console.Write("Enter temperature in Celsius: "); double celsius = Convert.ToDouble(Console.ReadLine()); // Convert to Fahrenheit double fahrenheit = (celsius * 9 / 5) + 32; // Output the result Console.WriteLine($"Temperature in Fahrenheit: {fahrenheit:F2}"); } }