Remainder of two numbers in JAVA

Remainder of two numbers in JAVA

In the previous blog we saw remainder of two numbers. Now, we will see about datatypes and find the remainder of two numbers.

Basic Data Type:- int, char, float, double

int Datatype:-Its an integer datatype .Its of 4 bytes .Its range is -2,147,483,648 to 2,147,483,647.

char Datatype:-Its an character datatype. Its of  2 bytes. 

float Datatype:-Its for floating point numbers. Its of  4 bytes.

double Datatype:-Its for large floating point numbers .Its of 8 bytes.

1.Remainder of two numbers using int datatype 

import java.io.*;

import java.util.*;

public class remainder{

    public static void main (String [] args)

    {

        int number1,number2,number3;

        System.out.println("Enter two numbers:");

        Scanner sc =new Scanner(System.in);

        number1=sc.nextInt();

        number2=sc.nextInt();

        number3=number1%number2;

        System.out.print("Remainder of two number is "+number3);

    }

}

Algorithm:-

1.Start 

2.Import the packages respectively.

3.Declare the variables number1 and number 2  by using the datatype int .Use the print statement and display a message "Enter two numbers:"

4.By using the scanner class get the input  by using System.in and create the object sc 

5.Get the first & second number by using scanner class .

6.By using number3 variable for remainder of  the two numbers number1 & number2 

7. The print statement gets displayed in the next line to  display a message "Remainder of two numbers" along with the Remainder of two numbers .

8.Stop.

Screenshot:-

1.Code Screenshot:-




2.Output Screenshot:-



In the next blog we will see about  ASCII value of a character.

0 Comments