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 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
Steps
- 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.
Example
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)
quotient:=a/b
remainder:=a%b
fmt.Println("Quotient is:",quotient)
fmt.Println("Remainder is:",remainder)
}
Output
Enter first number: 15 Enter second number: 7 Quotient is: 2 Remainder is: 1
Advertisements
