<\/span><\/h2>\n\n\n\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, c, sum, average float64\n\n\tfmt.Print(\"Enter the first integer: \")\n\tfmt.Scanln(&a)\n\n\tfmt.Print(\"Enter the second integer: \")\n\tfmt.Scanln(&b)\n\n\tfmt.Print(\"Enter the third integer: \")\n\tfmt.Scanln(&c)\n\n\tsum = a + b + c\n\taverage = sum \/ 3\n\n\tfmt.Print(\"The average of three number is = \", average)\n\n}<\/pre>\n\n\n\nOutput<\/strong><\/p>\n\n\n\nEnter the first integer: 8\r\nEnter the second integer: 5\r\nEnter the third integer: 14\r\nThe average of three number is = 9<\/code><\/pre>\n\n\n\n<\/span>How Does This Program Work?<\/strong><\/span><\/h2>\n\n\n\n\tvar a, b, c, sum, average float64\n<\/pre>\n\n\n\nWe have declared five float data type variables. The three variables (a<\/strong>, b<\/strong>, and c<\/strong>) will be used to store the integers entered by the user, while the sum<\/strong> and average<\/strong> variables will be used to store the sum and average of three numbers, respectively.<\/p>\n\n\n\n\tfmt.Print(\"Enter the first integer: \")\n\tfmt.Scanln(&a)\n\n\tfmt.Print(\"Enter the second integer: \")\n\tfmt.Scanln(&b)\n\n\tfmt.Print(\"Enter the third integer: \")\n\tfmt.Scanln(&c)\n<\/pre>\n\n\n\nThe program prompts the user to enter three integers. The three integers are taken as input using the fmt.Scanln()<\/strong> method.<\/p>\n\n\n\n\tsum = a + b + c\n<\/pre>\n\n\n\nThe sum of three variables is calculated with the help of the addition (+) operator. The obtained result is saved in the variable sum<\/strong>.<\/p>\n\n\n\n\taverage = sum \/ 3\n<\/pre>\n\n\n\nThe average of three numbers is then calculated using the formula: average = sum of three numbers \/ 3.<\/p>\n\n\n\n
The average of the three numbers gets stored in the average<\/strong> named variable.<\/p>\n\n\n\n\tfmt.Print(\"The average of three number is = \", average)\n<\/pre>\n\n\n\nIn the end, the average of three numbers, which is stored in the average<\/strong> named variable, is printed on the screen using the fmt.Print()<\/strong> method.<\/p>\n\n\n\n<\/span>Conclusion<\/strong><\/span><\/h2>\n\n\n\nIn this post, you learned how to write a program to find the average of three numbers using the Go programming language<\/strong>.<\/p>\n\n\n\nIf you have any doubts regarding the tutorial, leave your queries in the comment section.<\/p>\n","protected":false},"excerpt":{"rendered":"
In this post, we will learn how to write a program to find the average of three numbers using the Go programming language.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[808],"tags":[809],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/posts\/8460"}],"collection":[{"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/comments?post=8460"}],"version-history":[{"count":3,"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/posts\/8460\/revisions"}],"predecessor-version":[{"id":8463,"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/posts\/8460\/revisions\/8463"}],"wp:attachment":[{"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/media?parent=8460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/categories?post=8460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/tags?post=8460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}