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
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:
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.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics