/*Printing hello world in hindi*/
package main
import "fmt"
func main() {
fmt.Print("नमस्ते, दुनिया\n") /* fmt.Print("Hello, world\n")*/
}
NOTE: 1) These type of typing will generate error.
func main() /*A new line is given after the main() */
{
}
2) fmt.print("............") /* in print P should be upper case*/
PROGRAM 2
/*This prog shows declaration and printing of variables*/
package main
import "fmt"
func main() {
fmt.Print("This program will print the valu of a variable\n")
var a int = 5
fmt.Print(a) /*fmt.Print("The Value of a is ",a,"\n")
}
PROGRAM 3
/* Adding two variables and displaying the result*/
package main
import "fmt"
func main() {
var number1 int = 1
var number2 int = 2
var total int
total=number1+number2
fmt.Print(total)
}
PROGRAM 3
/*Adding, subtracting, multiplying and divding a given number and printing the results*/
package main
import "fmt"
func main() {
fmt.Print("This prog shows add, sub, mult and div\n")
var number1 int = 3
var number2 int = 3
var (
total int;sub int;product int;quo int
)
total = number1 + number2
sub = number1 - number2
product = number1 * number2
quo = number1 / number2
fmt.Print(total,sub,product,quo)
}
PROGRAM 4
/* Swapping two numbers */
package main
import "fmt"
func main() {
var a int = 1
var b int = 2
fmt.Print("The value of a and b is ",a,b)
a,b = b,a
fmt.Print("\nThe value of a and b after swap ",a,b,"\n")
}