PROGRAM TO DIVIDE A NUMBER WITHOUT USING DIVISION OPERATOR

 PROGRAM TO DIVIDE A NUMBER WITHOUT USING DIVISION OPERATOR


I/P:

64
8

O/P:
8


PROGRAM:


import java.util.*;
public class NumberDivisionwithoutOperators {
    public static void Divide(int a,int b)//64 8
    {
        int c=0;
        int d=0;
        while(a>=b)
        {
            c=a-b;
            d++;
            a=c;

        }
        System.out.println(d);
    }
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        Divide(a,b);
    }
    
}

//64
//8

//8

Comments

Popular posts from this blog

PROGRAM TO FIND FACTORIAL OF A NUMBER USING RECURSION

Program to Copy One Array to Another using Assignment operator

PROGRAM TO FIND THE COUNT OF PARTICULAR NUMBER IN AN ARRAY