w3resource

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

C# Sharp Basic: Exercise-14 with Solution

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

C# Sharp Code Editor:

Previous: Write a C# program that takes a number as input and then displays a rectangle of 3 columns wide and 5 rows tall using that digit.
Next: Write a C# program remove specified a character from a non-empty string using index of a character

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/csharp-exercises/basic/csharp-basic-exercise-14.php