Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
Golang Program to Convert Centimeters into Feet and Inches
Steps
- Take the height in centimeters and store it in a variable.
- Convert the height in centimeters into inches and feet.
- Print the length in inches and feet.
| Enter the height in centimeters: 50 The length in inches: 19.7 The length in feet: 1.64 |
Enter the height in centimeters: 153 The length in inches: 60.28 The length in feet: 5.02 |
Explanation
- User must enter the height in centimeters.
- The height in centimeters is multiplied by 0.394 and stored in another variable which now contains the height in inches.
- The height in centimeters is multiplied by 0.0328 and stored in another variable which now contains the height in feet.
- The converted height in inches and feet is printed.
Example
package main
import "fmt"
func main(){
var n int
fmt.Print("Enter the height in centimeters: ")
fmt.Scanf("%d", &n)
inches:=0.394*float32(n)
feet:=0.0328*float32(n)
fmt.Println("The length in inches:", inches)
fmt.Println("The length in feet:", feet)
}
Output
Enter the height in centimeters: 50 The length in inches: 19.699999 The length in feet: 1.64
Advertisements
