C# Program to Convert Celsius to Fahrenheit
Posted by Superadmin on August 15 2022 15:49:10

C# Program to Convert Celsius to Fahrenheit

 

 

This is a C# Program to perform celsius to fahrenheit conversion.

Problem Description

This C# Program Performs Celsius to Fahrenheit Conversion.

Problem Solution

Here the temperature is obtained in Celsius and is converted to Fahrenheit.

Program/Source Code

Here is source code of the C# program to perform Celsius to Fahrenheit conversion. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

/*
 * C# Program to Perform Celsius to Fahrenheit Conversion
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace program
{
    class Program
    {
        static void Main(string[] args)
        {
            int celsius, faren;
            Console.WriteLine("Enter the Temperature in Celsius(°C) : ");
            celsius = int.Parse(Console.ReadLine());
            faren = (celsius * 9) / 5 + 32;
            Console.WriteLine("0Temperature in Fahrenheit is(°F) : " + faren);
            Console.ReadLine();
 
        }
    }
}
Program Explanation

In this C# program, we are reading the temperature in celsius(°c) using ‘celsius’ variable. Multiply the value of ‘Celsius’ variable with 9 and add the resulted value with the value of 5. Again add the resulted value with the value of 32. Print the Fahrenheit value of the celsius.

 
Runtime Test Cases
 
Enter the Temperature in Celsius (°C) :  20
Temperature in Fahrenheit(°F)  is  : 68