Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; SEOFriendlyImages has a deprecated constructor in /home/tutorig3/public_html/wp-content/plugins/seo-image/seo-friendly-images.class.php on line 2

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/tutorig3/public_html/wp-content/themes/mts_interactive/options/php-po/php-po.php on line 185
Kotlin program to find Quotient and Remainder - Tutorialwing
Coronavirus Outbreak - 2020, 100+ dead in China, effected several countries, Checkout WHO Advices to stay safe

Kotlin program to find Quotient and Remainder

Greetings!
We have recently published 100+ articles on android tutorials with kotlin and java. If you need, you may visit Android Tutorial for beginners page. You can also check Kotlin Tutorial for beginners. Also, if you are interested in content writing, you can mail us at tutorialwing@gmail.com.

In this post, we will go through Kotlin program to find quotient and remainder when dividend is divided by divisor.
In other words, we are going to find quotient and remainder when a number is divided by another number in kotlin.

Kotlin program to find Quotient and Remainder

Sourcecode –

import java.util.*

fun main() {

    val read = Scanner(System.`in`)

    println("Enter dividend:")
    val dividend = read.nextInt()

    println("Enter divisor:")
    val divisor = read.nextInt()

    val quotient = dividend / divisor
    val remainder = dividend % divisor

    println("Quotient = $quotient")
    println("Remainder = $remainder")
}

When you run the program, output will be

Enter dividend:
25
Enter divisor:
3
Quotient = 8
Remainder = 1
Explanation:

At first, we are accepting two inputs (Dividend and Divisor) from user.
read.nextInt() method is being used to read input from user. So,
val dividend = read.nextInt() means read the value entered by user and store it in variable
dividend.

Similarly, we read the value(i.e. divisor) entered by user and stored it in divisor.

/ operator is used to get quotient when a number is divided by other number. So,
dividend / divisor will return quotient when dividend is divided by divisor.

% operator is used to get remainder when a number is divided by other number. So,
dividend % divisor will return remainder when dividend is divided by divisor.

Support Us

If you like Tutorialwing and would like to contribute, you can email an article on any educational topic at tutorialwing@gmail.com. We would love to publish your article. See your article on Tutorialwing and help others with your knowledge. Follow Facebook, LinkedIn, Google+, Twitter, Youtube for latest updates.
Greetings!
We have recently published 100+ articles on android tutorials with kotlin and java. If you need, you may visit Android Tutorial for beginners page. You can also check Kotlin Tutorial for beginners

Leave a Reply