FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 99   



Following program shows you how to print average of given 3 numbers.
In this program we get inputs from user and calculate average of given 3 numbers using following formula
Average of given 3 numbers = (input1 + input2 + input3) / 3

package main

import "fmt"

func main() {

  var input1 int
  var input2 int
  var input3 int
  var result int
  fmt.Println("Enter first number:")
  fmt.Scanf("%d", &input1)
  fmt.Println("Enter second number:")
  fmt.Scanf("%d", &input2)
  fmt.Println("Enter third number:")
  fmt.Scanf("%d", &input3)
  result = (input1 + input2 + input3) / 3
  fmt.Println("The average of three numbers: " , result)
  }

Output:

Enter first number:
 12
Enter second number:
 22
Enter third number:
 19
The average of three numbers:  17



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News