Golang Program to Take the Temperature in Celsius and Covert it to Farenheit

Go ProgrammingServer Side ProgrammingProgramming

Steps

  • Take the value of temperature in Celsius and store it in a variable.
  • Convert it to Fahrenheit.
  • Print the final result.
Enter the temperature in Celsius: 32
Temperature in Fahrenheit is: 89.6
Enter the temperature in Celsius: 48
Temperature in Fahrenheit is: 118.4

Explanation

  • User must first enter the value of temperature in Celsius.
  • Using the formula: f=(c*1.8)+32, convert Celsius to Fahrenheit.
  • Print the temperature in Fahrenheit.

Example

 Live Demo

package main
import "fmt"
func main(){
   var n int
   fmt.Print("Enter the temperature in Celsius:")
   fmt.Scanf("%d", &n)
   f:=(float32(n)*1.8)+32
   fmt.Println("Temperature in Fahrenheit is:", f)
}

Output

Enter the temperature in Celsius:32
Temperature in Fahrenheit is: 89.6
raja
Published on 31-Jul-2021 15:27:49
Advertisements