Golang Program to Read Two Numbers and Print their Quotient and Remainder

To print the Quotient and Remainder of two numbers, we can use the division operator and the modulo operator.

Let's take an Example:

  • a = 15 and b = 2
  • Quotient is 15/2 = 7
  • Remainder is 15 % 2 = 1


  • Define the variables, a and b.
  • Use print statement for the first number.
  • Use print statement for the second number.
  • Find the division of the numbers, a and b.
  • Find the remainder of the numbers, a and b.
  • Print the calculated division.
  • Print the calculated remainder.


 Live Demo

package main
import "fmt"
func main(){
   var a, b int
   fmt.Print("Enter first number: ")
   fmt.Scanf("%d", &a)
   fmt.Print("Enter second number: ")
   fmt.Scanf("%d", &b)
   fmt.Println("Quotient is:",quotient)
   fmt.Println("Remainder is:",remainder)


Enter first number: 15
Enter second number: 7
Quotient is: 2
Remainder is: 1

Updated on: 02-Aug-2021


Kickstart Your Career

Get certified by completing the course

Get Started