w3resource

C#: Program to convert from celsius degrees to Kelvin and Fahrenheit


Celsius to Kelvin and Fahrenheit

Write a C# program to convert Celsius degrees to Kelvin and Fahrenheit.
kelvin = celsius + 273
fahrenheit = celsius x 18 / 10 + 32

C# Sharp Exercises: Program to convert from celsius degrees to Kelvin and Fahrenheit

Sample Solution:

C# Sharp Code:

using System;

// This is the beginning of the Exercise14 class
public class Exercise14
{
    // This is the main method where the program execution starts
    public static void Main( )
    {
        // Declaration of variables
        Console.Write("Enter the amount of Celsius: "); // Prompting the user to enter Celsius temperature
        int celsius = Convert.ToInt32(Console.ReadLine()); // Reading Celsius input and converting it to an integer

        // Calculating and displaying the equivalent temperature in Kelvin
        Console.WriteLine("Kelvin = {0}", celsius + 273);

        // Calculating and displaying the equivalent temperature in Fahrenheit
        Console.WriteLine("Fahrenheit = {0}", celsius * 18 / 10 + 32);
    }
}

Sample Output:

Enter the amount of celsius: 40                                                                               
Kelvin = 313                                                                                                  
Fahrenheit = 104

Flowchart:

Flowchart: C# Sharp Exercises - Program to convert from celsius degrees to Kelvin and Fahrenheit

For more Practice: Solve these Related Problems:

  • Write a C# program that converts Celsius to Kelvin, Fahrenheit, and Rankine all in one operation.
  • Write a C# program to input Celsius and calculate the heat index if humidity is also provided.
  • Write a C# program that reads Celsius and prints advisory messages based on the temperature range.
  • Write a C# program that converts Celsius to Fahrenheit and checks if the result is divisible by 5.

Go to:


PREV : Rectangle Pattern with Number.
NEXT : Remove Character by Index.

C# Sharp Code Editor:



What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.